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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
WilliamMunguti
Frequent Visitor

Switch From Sum To Count with Radio Button

Is there a way to switch from sum to count of a value in powerbi? and not on a chart level while creating the visual? but have a drop down that lets you select whether to sum up the values along a column or to count them

1 ACCEPTED SOLUTION
v-junyant-msft
Community Support
Community Support

Hi @WilliamMunguti ,

You can do this using bookmarks or DAX, but you mentioned "not on a chart level while creating the visual", so you can only do it via DAX.

Here is my sample data:

vjunyantmsft_0-1738199515811.png


Create another table:

vjunyantmsft_1-1738199535270.png

And use this table to create a slicer:

vjunyantmsft_2-1738199713434.png

 


Use these DAXs to create measures:

Sum = SUM('Table'[Value])
Count = COUNT('Table'[Value])
Output = 
SWITCH(
    SELECTEDVALUE(Slicer[Button]),
    "COUNT", [Count],
    "SUM", [Sum],
    [Sum]
)

And the final output is as below:

vjunyantmsft_3-1738199736748.png

vjunyantmsft_4-1738199742926.png


Best Regards,
Dino Tao
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
WilliamMunguti
Frequent Visitor

Hi @v-junyant-msft 
Thanks for this. Let me try it out and will give you feedback

v-junyant-msft
Community Support
Community Support

Hi @WilliamMunguti ,

You can do this using bookmarks or DAX, but you mentioned "not on a chart level while creating the visual", so you can only do it via DAX.

Here is my sample data:

vjunyantmsft_0-1738199515811.png


Create another table:

vjunyantmsft_1-1738199535270.png

And use this table to create a slicer:

vjunyantmsft_2-1738199713434.png

 


Use these DAXs to create measures:

Sum = SUM('Table'[Value])
Count = COUNT('Table'[Value])
Output = 
SWITCH(
    SELECTEDVALUE(Slicer[Button]),
    "COUNT", [Count],
    "SUM", [Sum],
    [Sum]
)

And the final output is as below:

vjunyantmsft_3-1738199736748.png

vjunyantmsft_4-1738199742926.png


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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!