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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Peterkl
Regular Visitor

Calculate max value measure to use as max range in a chart when one column is sliced be two slicers

I have a report where I compare two products, lets say A and B. On the left a slicer where product A is selected and a column chart with the amount sold per year and for product B the same slicer and chart. With Edit interactions I make sure that the slicer and graph left don't filter the slicer and graph on the right and vice versa. Product A has as maximal amount of 50 and product B has as maximal amount of 100, how do I get a measure with the max amount selled in a year for both products, 100 in this case so I can use conditional formatting as the max range for the Y axis of both graphs. There are also other products in the table so the measure to get the max value can only check for the mas value of the two filtered products. Normally I am able to make a measure to get the max value but with two slicers on the same tabel I don't get it working.

Example.PNG

 

Here is a link to the pbix file, with tabblad Problem with the problem and two tabblads with expected results.
https://hzpcgroup-my.sharepoint.com/:u:/g/personal/peter_vantklooster_stet-potato_com/EY_12BwrCx5Mr8... 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Peterkl 

 

You can try the following methods.
New table:

Slicer = VALUES('Table'[Product])

Measure:

Slicer Value = CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),[Product]=SELECTEDVALUE(Slicer[Product])&&[Year]=SELECTEDVALUE('Table'[Year])))

Turn the second figure into the one shown.

vzhangti_0-1690876615316.png

Measure = 
Var _Sum1=CALCULATE(MAX('Table'[Amount]),ALLEXCEPT('Table','Table'[Product]))
Var _Sum2=MAXX(FILTER(ALL('Table'),[Product]=SELECTEDVALUE(Slicer[Product])),[Slicer Value])
Return
IF(_Sum1>=_Sum2,_Sum1,_Sum2)

Use this measure to set the maximum value of the Y-axis of the first plot.

vzhangti_1-1690876684076.png

Result:

vzhangti_2-1690876788132.pngvzhangti_3-1690876810851.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Peterkl 

 

You can try the following methods.
New table:

Slicer = VALUES('Table'[Product])

Measure:

Slicer Value = CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),[Product]=SELECTEDVALUE(Slicer[Product])&&[Year]=SELECTEDVALUE('Table'[Year])))

Turn the second figure into the one shown.

vzhangti_0-1690876615316.png

Measure = 
Var _Sum1=CALCULATE(MAX('Table'[Amount]),ALLEXCEPT('Table','Table'[Product]))
Var _Sum2=MAXX(FILTER(ALL('Table'),[Product]=SELECTEDVALUE(Slicer[Product])),[Slicer Value])
Return
IF(_Sum1>=_Sum2,_Sum1,_Sum2)

Use this measure to set the maximum value of the Y-axis of the first plot.

vzhangti_1-1690876684076.png

Result:

vzhangti_2-1690876788132.pngvzhangti_3-1690876810851.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks Charlotte,

 

I think this will help me. After my holiday I will try it.

 

Best regards,

Peter

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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