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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Slicer that changes calculations within visuals

Hello all,

 

I have data of calls for their duration stretching over a range of days. Currently, I am displaying the data to show the total number of calls for each day of the week as below:

 

image.png

 

Right now, it shows the total number of calls. I know how to change the column values to show the average calls per day, but I'm interested in adding a slicer to the side with the "Total" and "Average" options that, when selected changes the calculation in the visual automatically. Is this possible?

 

3 REPLIES 3
parry2k
Super User
Super User

@Anonymous yes that is possible, create a table using following DAX under modelling tab, clicking Data Table

 

Aggregation Selection = DATATABLE( "Aggregation Method", STRING, { { "Average" }, { "Sum" } } )

it will create a table in your model, drop "Aggregation Method" from this table in a slicer and add  a measure or change existing

 

Calls by Aggregation Method = 
VAR __aggregationMethod = SELECTEDVALUE( 'Aggregate Selection'[Aggregation Method], "Sum" )
RETURN
IF ( __aggregationMethod = "SUM", <sum measure>, <average measure> )

 

 

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2kI forgot to mention that when averaging, I have other visuals that need to average the call duration by call hour of the day (24 hour clock), and also by caller ID. So I'm not sure if creating a measure is the best to average all the visuals simulatenously. Your solution, however works if there was only one visual.

You can create avg and sun measures and use those wherever you want and the same measure use in this if condition.


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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