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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.