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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
varutvu
Regular Visitor

Use slicer to select which column to sum

Hi everyone,

 

I have a table with 30 columns, say C1...C30. And need to create a dashboard where a user can use slicer to pick which column to sum, and output it on a graph. E.g. when user selects C7 on slicer, then the graph plots a sum of column [C7].

 

I know one way to achieve this is to create 30 measures and use SWITCH() function. But is there a way to create just single measure and reference column name with a variable?

 

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

If you're able to use the query editor, select C1...C30 and click unpivot columns. That'll allow you to easily do it with one calculation. 

Karlos_0-1597574313986.png

Karlos_1-1597574327172.png

 

You should also be able to use the UNION function in DAX, see below for an example 

https://stackoverflow.com/questions/50213905/is-it-possible-to-unpivot-in-power-bi-using-dax

 

 

View solution in original post

2 REPLIES 2
AllisonKennedy
Super User
Super User

@varutvu
I agree with @Anonymous
Without knowing more about what data is in columns 1 - 30, I also think this sounds like data that might be best unpivoted.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

If you're able to use the query editor, select C1...C30 and click unpivot columns. That'll allow you to easily do it with one calculation. 

Karlos_0-1597574313986.png

Karlos_1-1597574327172.png

 

You should also be able to use the UNION function in DAX, see below for an example 

https://stackoverflow.com/questions/50213905/is-it-possible-to-unpivot-in-power-bi-using-dax

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors