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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.