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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
Anonymous
Not applicable

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 @Anonymous 
Thanks for this. Let me try it out and will give you feedback

Anonymous
Not applicable

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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