Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ce2016
Frequent Visitor

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])
))

 

1 ACCEPTED SOLUTION

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.

1.PNG

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 monthfilter on weekfilter on week

Please download the attachment to check more details.

Best Regards,
Angelia

View solution in original post

7 REPLIES 7
v-huizhn-msft
Employee
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

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.

 

Weekly.PNG

 

 

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

 

Monthly.PNG

 

 

 

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

Hey Angelina,

 

I uploaded a sample pbix. file on dropbox:

 

https://www.dropbox.com/s/kpdoqlrtc32egnt/Pareto%20Chart%20Sample.pbix?dl=0

 

Thank you for your great support!

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.

1.PNG

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 monthfilter on weekfilter on week

Please download the attachment to check more details.

Best Regards,
Angelia

Hi Angelina @v-huizhn-msft, I just noticed that the cumulated amount of deliveries is not correct if I remove the filters or select on monthly level. Only when the filters are set on a specific calendar week, the values are correct...Can you check again please?

 

 

Hi all!

 

I'm trying to create the similar report.

I put formulas as Angelina wrote above.

But I have strange results.

Cumulative total amount is wrong. I don't understand why it happens.

 

2018-03-09_11-39-25.png

 

My pbix file is here: link

Can anybody help me?

 

Thanks in advance,

Alex.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.