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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Making Switch function return a column in a table and not a measure (PowerBI DAX)

What I'm trying to do is to change measures using slicers in Power BI Desktop. I have found some examples of people who have done that (for instance this ) .

What they do is that they create a table where there are ID and Measure names. The 'Measure names' column of this table will be used as field value in the filter of the visualization. Then, they create a switch function that, given a certain value in the filter, switch the value in the filter to a measure. You can see an example below:

Measure Value = SWITCH(
                            MIN('Dynamic'[Measure ID]) ,
                            1,[Max Temp],
                            2,[Min Temp],
                            3,[Air Pressure],
                            4,[Rainfall],
                            5,[Wind Speed],
                            6,[Humidity]
                            )

Where 'Dynamic' is a group containing a measure ID and a Measure name:

Dynamic:

Measure ID | Measure Name
1          |  Max Temp
2          |  Min Temp
3          |  Air Pressure
4          |  Rainfall
5          |  Wind Speed
6          |  Humidity

All of the 'Measure Name' are measures as well.

My problem is: I have too many columns (400!) and I cannot turn them into measures one by one. It will take days. I was thinking that maybe I could use the switch function so that it returns the column in the table and NOT the corresponding measure. However I cannot just insert 'Name of the table'['Name of the column'] in the switch function as result parameter.

Does anyone know how to make the function Switch return a column and not a measure? (Or any other suggestion)

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could use DAX Studio to export all the columns and import the files into Power BI to combine them as one table. Then you could use the columns name in the Switch function.

select * from $SYSTEM.TMSCHEMA_COLUMNS

2.PNG 

 

https://daxstudio.org/

https://daxstudio.org/documentation/features/

 

Best Regards,
Xue Ding
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

5 REPLIES 5
sayi1627
New Member

I have a table in power bi name sheet1 and i want to use the columns of that sheet in a new measure for a switch function ,but when i am trying to use sheet1 it is not coming?

 

MehdiJafari
Regular Visitor

Having the same question. have you found a solution yet?

v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could use DAX Studio to export all the columns and import the files into Power BI to combine them as one table. Then you could use the columns name in the Switch function.

select * from $SYSTEM.TMSCHEMA_COLUMNS

2.PNG 

 

https://daxstudio.org/

https://daxstudio.org/documentation/features/

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , I did not get it completely. If you looking for measure slicer refer

https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/500115

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

This solution implies creating new measures. I should do it 400 times. Isn't it possible to do it without measures (using table and columns)? 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.