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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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