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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Change Measure from Average to Median (or any other computation) via Slicer

Hi Guys, I would like to know if there is a trick on changing the computation of dashboard from Average to Sum or Median to Sum via Slicer? 

Thank you

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Yes use this slicer on the dashboard/report. Your chart calculations will change based on the selection in the slicer. It is the same logic, you will be using a chart visual in place of a simple table visual.

 

I just showed you on a table visual. Try it on a line chart visual, it will work.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

5 REPLIES 5
Pragati11
Super User
Super User

Hi @Anonymous ,

 

Yes you can do this in Power BI easily by using following steps:

 

1. Create a simple table in Power BI using Enter Data option for different calculation types you want: (modify these based on your requirement)

Pragati11_0-1636370832284.png

You will end up with following table:

Pragati11_1-1636370862957.png

Now suppose, in my scenario I want to modify the calculation type of Sales by Category.

Pragati11_2-1636370915450.png

I will start by creating a slicer by moving Calc Type column to it: (Make sure to make the slicer Single Select as logically only one type of calculation can be shown at a point)

 

Pragati11_6-1636371328415.png

 

Now I will create a measure something as below:

Calc_Type_Sales = 
var calcType = SELECTEDVALUE('Calculation Type'[Calc Type])
RETURN
SWITCH(
    TRUE(),
    calcType = "Sum", SUM(ClothingSales[Sales]),
    calcType = "Average", AVERAGE(ClothingSales[Sales]),
    MEDIAN(ClothingSales[Sales])
)

 

Now I will move this above measure against Category column in my data in a simple table visual:

Pragati11_5-1636371310962.png

 

Now start selecting the values from the slicer and the Calc_Type_Sales values changes for each category in the left table:

calccType.gif

It shows:

  • SUM of Sales when Sum is selected from the slicer
  • AVERAGE of Sales when Average is selected from the slicer and so on

So the calculation type for Sales changes based on the selection I make in the slicer on the right.

You can modify this solution to your requirement by adding other calculation types as well.

 

Let me know how you get on with this solution.

 

Thanks,

Pragati

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Hi @Pragati11 
That is a wonderful idea however, is it possible to use it on a dashboard, for example:

This is the average count

Daniel_Pel_4-1636436570437.png

 

and this is the median:

Daniel_Pel_3-1636436535253.png

 

I want the dashboard itself to switch its computation using slicer. Apologies for the confusion

Thank you in advance.

 

Hi @Anonymous ,

 

Yes use this slicer on the dashboard/report. Your chart calculations will change based on the selection in the slicer. It is the same logic, you will be using a chart visual in place of a simple table visual.

 

I just showed you on a table visual. Try it on a line chart visual, it will work.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Hi @Pragati11 

Its working! Thank you so much for your help!

Anonymous
Not applicable

Hi @Pragati11 
Its working!!!! 
Thank you so much for your help!

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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