Data Customization for Pareto

Chefsohail

Board Regular
Joined
Oct 3, 2020
Messages
90
Office Version
  1. 365
Platform
  1. Windows
Hi Team,

I am working on a data set and need help in arranging the data set for a pareto chart. I have a dynamic data and if i arrange it every time, it will be a manual task. I need assistance where i can eliminate the manual work.

Below is the situation -

I have my data arranged in following pattern. I perform audits and mark errors on Transactions. Lets say Number column is the transaction number. And one transaction can have multiple errors. I have given an example below of 4 errors types.

Table 1
NumberError1Error2Error3Error4Error_CountCTQ_CountScore (number format %)
1=COUNTIF(B2:E2,0)=COUNT(B2:E2)=SUM(B2:E2)/COUNT(B2:E2)
2=COUNTIF(B3:E3,0)=COUNT(B3:E3)=SUM(B3:E3)/COUNT(B3:E3)
3=COUNTIF(B4:E4,0)=COUNT(B4:E4)=SUM(B4:E4)/COUNT(B4:E4)
4=COUNTIF(B5:E5,0)=COUNT(B5:E5)=SUM(B5:E5)/COUNT(B5:E5)
5=COUNTIF(B6:E6,0)=COUNT(B6:E6)=SUM(B6:E6)/COUNT(B6:E6)

Eg with data: Here score of 1 means No Error. If transaction has errors, the score given to error type (Error1, Error2, Error3, Error4) is 0.

Table 2
NumberError1Error2Error3Error4Error_CountCTQ_CountScore
1​
1​
1​
1​
1​
0​
4​
100%​
2​
0​
0​
0​
0​
4​
4​
0%​
3​
1​
0​
0​
0​
3​
4​
25%​
4​
1​
1​
0​
0​
2​
4​
50%​
5​
1​
1​
1​
0​
1​
4​
75%​

I need to perform an error analysis now to understand which error is repeated the most. And I need this to be dynamic. If someone can share a solution that'll be great. If nothing rings a bell, and if you can help me convert this to below, that'll be awesome.

Table 3
NumberError Type
2​
Error1
2​
Error2
2​
Error3
2​
Error4
3​
Error2
3​
Error3
3​
Error4
4​
Error3
4​
Error4
5​
Error4

So basically -
1. Transaction #1 did not have any errors. Hence data is not included in Table 3.
2. Transaction #2 had 4 errors. The column wise data is now split to rows with multiple entries of the same transaction with different error type.
3. Transaction #3 has 3 errors, Transaction #4 has 2 errors and Transaction #5 has 1 error.

I have tried to simplify the query here. However in actual, my data set contains multiple error types and many other columns needed for the project.
Please do let me know if we have any questions
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
May be a possible solution that can work.

Can we create a vba code for this?

I need to paste my data in Sheet1.. and once the code is executed , it creates the data as I want in another sheet.. If someone can help with it, I'll be glad.

Please find below the headers. For data privacy purposes I cant add alot of information, hence I am giving common header names. However I will update the corresponding headers in the VBA code.

Column 1Column 2Column 3Column 4Column 5Column 6Error 1Error 2Error 3Error 4Error 5Error 6Error 7Error 8Error 9Error 10Error 11Error 12Error 13Error 14Quality Met %RemarksError_CountCTQ_CountAQS TargetCluster LeadWK#
 
Upvote 0
For a Pareto chart, don't you want to summarise your errors in order of frequency, like this?

ABCDE
1NoError1Error2Error3Error4
211111
320000
431000
541100
651010
7
8Chart:
9Error44
10Error23
11Error33
12Error11
Sheet1
Cell Formulas
RangeFormula
C9:D12C9=SORT(TRANSPOSE(VSTACK(B1:E1,BYCOL(B2:E6,LAMBDA(c,COUNTIF(c,0))))),2,-1)
Dynamic array formulas.
 
Upvote 0
Thanx @StephenCrump for writing.

I have used a similar solution for the time being. However it doesnt make my Pareto Chart Dynamic. Eg: If i need pareto based on period or for a smaller team.
I'll be adding a slicer and timeline to make it dynamic.
 
Upvote 0
I need to paste my data in Sheet1.. and once the code is executed , it creates the data as I want in another sheet.. If someone can help with it, I'll be glad.

I have used a similar solution for the time being. However it doesnt make my Pareto Chart Dynamic. Eg: If i need pareto based on period or for a smaller team.
I'll be adding a slicer and timeline to make it dynamic.

You'll need to be a lot more specific about what you want your macro to do.

- What does a realistic data set look like?
- What do you want the macro to do with it, and what does the required output look like for the data provided?
- What do you mean by making the Pareto chart dynamic "based on period or for a smaller team"?
 
Upvote 0
You'll need to be a lot more specific about what you want your macro to do.

- What does a realistic data set look like?
- What do you want the macro to do with it, and what does the required output look like for the data provided?
- What do you mean by making the Pareto chart dynamic "based on period or for a smaller team"?

Thanx for writing @StephenCrump, below are the details.

- What does a realistic data set look like?
The realistic data set is as below.
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
NumberResolved ByResolved DateReopen CountBreach StatusPRBFirst Update in WorklogDetailed Analysis (Technical & Business Language)Closure NotesOn Hold StateOther Team InvolvementRe-PrioritizeDelayed/ Normal AssignmentNo Action by L2Store Call3 Strikes (Store Call)PRB/KBA LinkingKBA UpdationStore Personal full nameValid Reopened - ReasoningQuality Met %RemarksError_CountCTQ_CountAQS TargetCluster LeadWK#
INC12345671SpiderMan
10/27/2022​
0​
BreachedPRB1234561
1​
1​
1​
NaNaNaNaNa
1​
Na
1​
Na
1​
Na
100%​
Excellent06Black Panther41
INC12345672SuperMan
10/27/2022​
1​
Not BreachedPRB1234562
1​
1​
1​
NaNaNaNaNa
1​
Na
1​
Na
1​
Na
100%​
Excellent07Black Panther41
INC12345673BatMan
10/27/2022​
2​
Not BreachedPRB1234563
1​
1​
1​
NaNaNaNaNa
1​
Na
1​
Na
1​
Na
100%​
Excellent07Black Panther41
INC12345674Captain America
10/27/2022​
3​
Not Breached
0​
0​
1​
1​
NaNaNaNaNa
0​
Na
1​
Na
1​
Na
67%​
Feedback shared26Doctor Strange41
INC12345675Thor
10/27/2022​
4​
Breached
1​
1​
1​
0​
1​
NaNaNa
0​
Na
0​
Na
1​
Na
63%​
Feedback shared36Doctor Strange41
INC12345676Wonder Woman
10/27/2022​
5​
Not BreachedPRB1234566
0​
1​
1​
NaNaNaNaNa
0​
Na
1​
Na
1​
Na
67%​
Feedback shared27Doctor Strange41
INC12345677Black Widow
10/27/2022​
6​
Breached
1​
1​
1​
NaNaNaNaNa
1​
Na
1​
Na
0​
Na
83%​
Feedback shared17Doctor Strange41
INC12345678Iron Man
10/27/2022​
7​
Not Breached
0​
0​
1​
1​
NaNaNaNaNa
1​
Na
0​
Na
1​
Na
67%​
Feedback shared27Doctor Strange41
INC12345679Hulk
10/27/2022​
8​
Not BreachedPRB1234569
1​
1​
1​
NaNaNaNaNa
1​
Na
1​
Na
1​
Na
100%​
Excellent07Doctor Strange41

What do you want the macro to do with it?
The workbook needs to have 2 Sheets. Input and Output
I will copy and paste the above data in the input sheet.
In the input sheet -
The macro needs to look for '0' (zeros starting Column G through Column T
Lets say for first entry INC12345671.
The Quality Met % (Column U) for this is 100%, so the macro doesnt need to do anything and can move to the next one...
INC12345672 is also 100%
INC12345673 is also 100%
However the 4th one is INC12345674 = 67% as it has errors.
So the macro should check column G for it. There will be three possibilities - either the entry will be 1 or 0 or Na
if it is 1/Na, the macro can move to the next column. However if it is '0' then the macro needs to copy data from Column A through F and column Z of the same row and paste it in an output sheet.

NumberResolved ByResolved DateReopen CountBreach StatusPRB
INC12345674Captain America
10/27/2022​
3​
Not Breached
0​

The macro should create additional column in it named 'Error Type'

NumberResolved ByResolved DateReopen CountBreach StatusPRBError Type
INC12345674Captain America
10/27/2022​
3​
Not Breached
0​

and the corresponding error (header) needs to be mentioned in the error type column and data from corresponding Column Z to be pasted next to it.

NumberResolved ByResolved DateReopen CountBreach StatusPRBError TypeCluster Lead
INC12345674Captain America
10/27/2022​
3​
Not Breached
0​
First Update in WorklogDoctor Strange

Now the macro needs to move to the next column H.
Now since column H, I, J, K, L, M and N either have 1 or Na... it can skip and directly move to column O which has '0'

Now the macro will again copy Column A through F of the same row and paste it in an output sheet and the corresponding error (header) needs to be mentioned in the error type column.

NumberResolved ByResolved DateReopen CountBreach StatusPRBError TypeCluster Lead
INC12345674Captain America
10/27/2022​
3​
Not Breached
0​
First Update in WorklogDoctor Strange
INC12345674Captain America
10/27/2022​
3​
Not Breached
0​
Store CallDoctor Strange

Then until Column T, the rest of the data has either Na or 1. So can skip and move to the next row.

what does the required output look like for the data provided?
The required data should look like below.

NumberResolved ByResolved DateReopen CountBreach StatusPRBError TypeCluster Lead
INC12345674Captain America
10/27/2022​
3​
Not Breached
0​
First Update in WorklogDoctor Strange
INC12345674Captain America
10/27/2022​
3​
Not Breached
0​
Store CallDoctor Strange
INC12345675Thor
10/27/2022​
4​
BreachedOn Hold StateDoctor Strange
INC12345675Thor
10/27/2022​
4​
BreachedStore CallDoctor Strange
INC12345675Thor
10/27/2022​
4​
BreachedPRB/KBA LinkingDoctor Strange
INC12345676Wonder Woman
10/27/2022​
5​
Not BreachedPRB1234566First Update in WorklogDoctor Strange
INC12345676Wonder Woman
10/27/2022​
5​
Not BreachedPRB1234566Store CallDoctor Strange
INC12345677Black Widow
10/27/2022​
6​
BreachedStore Personal full nameDoctor Strange
INC12345678Iron Man
10/27/2022​
7​
Not Breached
0​
First Update in WorklogDoctor Strange
INC12345678Iron Man
10/27/2022​
7​
Not Breached
0​
PRB/KBA LinkingDoctor Strange

What do you mean by making the Pareto chart dynamic "based on period or for a smaller team"?
I only need the macro to prepare the data as above.
The Pareto chart that I have prepared has timeline and slicers connected to it. So when I need Pareto analysis for a Team. The chart will present data accordingly. Likewise since we have resolved date in the data. I can select the period that I need the pareto for and for a specific team. The system will display the information accordingly.
Hope that clarifies.

Please do let me know if we have any other questions.
 
Upvote 0
Try:

VBA Code:
Sub Test()

    Dim vIn As Variant, vOut As Variant, Header As Variant
    Dim NoCols As Long, Col_1 As Long, Col_2 As Long, i As Long, j As Long, k As Long, count As Long

    NoCols = 26
    Col_1 = 7
    Col_2 = 20
    
    With Worksheets("Input")
        Header = Range(.Cells(1, Col_1), .Cells(1, Col_2)).Value
        vIn = .Range("A2").Resize(.Range("A" & Rows.count).End(xlUp).Row - 1, NoCols).Value2
    End With
    ReDim vOut(1 To UBound(vIn) * (Col_2 - Col_1 + 1), 1 To Col_1 + 1)
        
    For i = 1 To UBound(vIn)
        If vIn(i, Col_2 + 1) < 1 Then
            For j = Col_1 To Col_2
                If vIn(i, j) = 0 Then
                    count = count + 1
                    For k = 1 To Col_1 - 1
                        vOut(count, k) = vIn(i, k)
                    Next k
                    vOut(count, Col_1) = Header(1, j - Col_1 + 1)
                    vOut(count, Col_1 + 1) = vIn(i, NoCols)
                End If
            Next j
        End If
    Next i

    If count > 0 Then
        Worksheets("Output").Range("A2").Resize(count, UBound(vOut, 2)).Value = vOut
        MsgBox "Finished"
    Else
        MsgBox "No errors"
    End If
    
End Sub
 
Upvote 0
Solution
Awesome. Thanx for the great help @StephenCrump . You've saved a lot of my manual effort.
I would like to learn this skill.

Will you please advice how do i start?
 
Upvote 0
The best way to learn VBA is to start coding. Start simple, and build up as your knowledge and experience grows.

There are many VBA resources that may be helpful listed on this thread: Big Shoutout!
 
Upvote 0

Forum statistics

Threads
1,215,124
Messages
6,123,187
Members
449,090
Latest member
bes000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top