Forum Discussion

ce2016's avatar
ce2016
Frequent Visitor
8 years ago
Solved

Pareto Chart with multiple aggregation levels

Dear all,

 

I am trying to create a pareto chart that allows me to visualize the amount of deliveries categorized by different codes, whereas I am able to switch on slicer filter from year, to months, to calendar week.

 

The data source is one huge excel file with data on very granular level.

 

So far I succeeded in getting a correct ranking, which is neccessary to cumulate the numbers.

 

However, only the cumulation on the most granular level is correct and I think it has something to do with this ALLEXPECT function. If I remove let's say Calendar Week (Calendar Year/Week) from the ALLEXPECT statement then the cumulation on monthly level is correct, but overall year and weekly is incorrect.

 

Do you have any ideas how I could fix the code?

DC Analysis is the name of the table, Delivery Code labels the respective delivery (direct, indirect, express,...)

 

 

Ranking = RANKX(ALL('DC Analysis'[Delivery Code]);
			CALCULATE(SUM('DC Analysis'[Amount of Deliveries]);
			ALLEXCEPT('DC Analysis';'DC Analysis'[Delivery Code];'DC Analysis'[Calendar Year/Month];'DC Analysis'[Calendar Year/Week])
							);;DESC)


Cumulative Total = CALCULATE(
SUM('DC Analysis'[Amount of Deliveries]);
FILTER(ALLSELECTED('DC Analysis');
[Ranking]<= MAXX('DC Analysis';[Ranking])
))

 

  • Hi ce2016,

    After check in details, I get expected results eventually. The "MAXX('Sample',[RankingSample])" in your formula is wrong, you can create another measure to test, I create another measure named "Test max of RankingSample", it should returen the max value utill current rows, while it returns wrong result, so please correct using VAR in DAX, like [current max Measure] measure, then you can use it in your cumulative total measure.

    Test max of RankingSample = MAXX('Sample',[RankingSample])
    current max Measure = VAR rr=[RankingSample]
    RETURN(rr)


    Then change your formula as follows,

    New Cumulative TotalSample = VAR rr=[RankingSample]
    RETURN( CALCULATE(
    	SUM('Sample'[Amount of Deliveries]),
    	FILTER(ALLSELECTED('Sample'),
    		[RankingSample]<= rr
    	)))
    
    Cumulated Percentage = [New Cumulative TotalSample]/[Total per DC]


    Now when you can get expected result whether the filter is set on month or week.

    filter on monthfilter on week

    Please download the attachment to check more details.

    Best Regards,
    Angelia

7 Replies

  • v-huizhn-msft's avatar
    v-huizhn-msft
    Microsoft Employee

    Hi ce2016,

    I think you should rank all your rows based on each day. Use the Calendar Year/Day in ALLEXCEPT statement, and check if it works fine.

    In addition, do you SUM('DC Analysis'[Amount of Deliveries]) in ranking calculated column? Could you please share your sample table model with dummy data for further analysis.

    Best Regards,
    Angelia

    • ce2016's avatar
      ce2016
      Frequent Visitor

      Hey Angelina v-huizhn-msft, thanks for helping me out.

       

      I put the Calendar Year / Day in the Allexpect ranking and removed all other ones but now the ranking is all wrong.

      SUM('DC Analysis'[Amount of Deliveries]) is done as a measure. As column I did get a wrong ranking.

       

      This is what the underlying table looks like (this is just an excerpt)

       

      Calendar Year/MonthCalendar Year/WeekActual delivery dateDelivery CodeCust.Hier.:Level 3Cust.Hier.:Level 4Cust.Hier.:Level 5Amount of Delivery
      09.201739.201725.09.2017ABL3 Customer AL4 Customer AL5 Customer A15555
      09.201739.201725.09.2017CDL3 Customer AL4 Customer AL5 Customer A6000
      09.201739.201725.09.2017EFL3Customer BL4 Customer BL5 Customer B54666
      09.201739.201725.09.2017GHL3 Customer AL4 Customer AL5 Customer A8036
      09.201739.201725.09.2017CAL3 Customer BL4 Customer BL5 Customer A7110
      09.201739.201725.09.2017ABL3 Customer AL4 Customer AL5 Customer A5022
      09.201739.201725.09.2017ABL3 Customer AL4 Customer AL5 Customer A200
      09.201739.201725.09.2017DDL3 Customer AL4 Customer BL5 Customer B300
      09.201739.201725.09.2017CDL3 Customer CL4 Customer CL5 Customer C400
      09.201739.201726.09.2017EFL3 Customer AL4 Customer AL5 Customer A1152
      09.201739.201727.09.2017CAL3 Customer AL4 Customer AL5 Customer A1152

       

      This what the graph and figures look like if the ALLEXCPECT statement includes the items Delivery Code, Calendar Year/Monthly and Calendar Year/Weekly, whereas the filter is set on a specific week.

       

       

       

      This what the graph and figures look like with the same ALLEXCPECT statement when the filter is set on a month.

       

       

       

       

      • v-huizhn-msft's avatar
        v-huizhn-msft
        Microsoft Employee

        Hi ce2016,

        Do you mind share your .pbix file for further analysis? It's hard to find the specific reason by the screenshot you shared.

        Best Regards,
        Angelia