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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
anwarbi
Helper III
Helper III

Fixing the measure that responds to slicer

Hi,

I have created the below measure,  so that if i select  a 'vendor name' from the drop down slicer, it should subtract the average score (of the selected vendor from the slicer) from the peer average score (the second part of the measure which adds a filter of related peers- which are also a group of vendors).

 

The result that i am getting however is incorrect as it only gives me the average score of the selcted vendor in the output and does not consider subtractraction. 

 

I think this measure needs to add some variable in the begining so that the measure responds to the selected vendor from the slicer. 

 

Score deviation with peer avg. = AVERAGE(Sheet1[Score])- (CALCULATE(AVERAGE(Sheet1[Score]), Sheet1[related Peers]<>""))
 
Your help will be appreciated.
7 REPLIES 7
amitchandak
Super User
Super User

@anwarbi , if that means blank is should is not(isblank([related peer]))

example

 

Score deviation with peer avg. = AVERAGE(Sheet1[Score])- (CALCULATE(AVERAGE(Sheet1[Score]),filter(all(Sheet1),  not(isblank([related peer]))  && [related peer] <> "" ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks Amit for your help.

 

Score deviation with peer avg. = AVERAGE(Sheet1[Score])- (CALCULATE(AVERAGE(Sheet1[Score]),filter(all(Sheet1),  not(isblank([related peer]))  && [related peer] <> "" ))

The above measure you suggested kind of works with the slicer, however it calculates an aggregate average value. so if i create a matrix table then all the cells in the table are populated with similar value.

 

In a matrix table the average values should correspond to the parameter in the row and column.

 

I beleive we are using All function in the measure, which might be causing this issue.

 

below is the example of the output that i am getting with the current measure and another table shows what i should get.

e.g. Current output

 Location ALocation BLocation C
Prod A6.96.96.9
Prod B6.96.96.9
Prod C6.96.96.9

 

e.g. Expected output

 Location ALocation BLocation C
Prod A5.26.55.7
Prod B6.95.36.2
Prod C6.15.96.7

 

Thanks.

Anonymous
Not applicable

Hi @anwarbi 

I've updated your code to make it easier to understand.

Score deviation with peer avg. = 
VAR _Part1 = AVERAGE(Sheet1[Score])
VAR _Part2 = CALCULATE(AVERAGE(Sheet1[Score]),filter(all(Sheet1),  not(isblank([related peer]))  && [related peer] <> "" )
RETURN
_Part1 - _Part2

Your measure [Score deviation with peer avg. ] is calculated by two parts.  Only _Part2 is filtered by ALL function. _Part2 will return the same result in your Matrix, but _Part1 won't. So I am confused about why your measure will always return 6.9.

And the filter in _Part2 not(islbank...) is the same as [related peer] <>"". You just need one of them. 

If you want _Part2 won't be filtered by Vendor slicer, you can update your code as below.

Score deviation with peer avg. = 
VAR _Part1 = AVERAGE(Sheet1[Score])
VAR _Part2 = CALCULATE(AVERAGE(Sheet1[Score]),filter(all(Sheet1),[related peer] <> ""&&Sheet1[Prod]=MAX(Sheet1[Prod])&&Sheet1[Location]=MAX(Sheet1[Location]))
RETURN
_Part1 - _Part2

 

Best Regards,
Rico Zhou

 

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

 

Thanks Rico. 

 

I will test your solution, however i did not understand the below addition in the measure, why it is needed.

Sheet1[Prod]=MAX(Sheet1[Prod])&&Sheet1[Location]=MAX(Sheet1[Location]))

 

Anonymous
Not applicable

Hi @anwarbi 

This is to let _Part2 to calculate the average by filter Prod and Location. Maybe I have misunderstanding in your requirement. Please share a sample with me and show me a screenshot to show me the result you want. I need to know your data model to understand your calculate logic.

 

Best Regards,
Rico Zhou

 

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

amitchandak
Super User
Super User

@anwarbi , Based on what I got, it should be

 

Score deviation with peer avg. = AVERAGE(Sheet1[Score])- (CALCULATE(AVERAGE(Sheet1[Score]),all() ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks Amit,

 

However, I think the solution does not consider the (Sheet1[related Peers]<>"") filter that i have added in the measure. 

Also, I forgot to mention that this measure would be used a rule for conditional formatting a table.

 

Thanks.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.