Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (11.1k points)

I was trying to change the measures using the slicer in the Power Bi Desktop. There are few examples which I found, They have created a table which have ID and measure names and they have created a switch function as shown in the below example

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

                            ) 

Dynamic is a group which contain ID and Measure names 

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

But here I am having some many columns and cannot convert into the measures one by one

Is there anyway to solve it? 

1 Answer

0 votes
by (22.5k points)
edited by

You should able to unpivot all the data which looks like this

ID | ColumnName   | Value
---+--------------+-------
1  | Max Temp     |
1  | Min Temp     |
1  | Air Pressure |
1  | Rainfall     |
1  | Wind Speed   |
1  | Humidity     |
...

and then create a calculated field Dynamic which can be use as a slicer

Dynamic = DISTINCT ( Unpivoted[ColumnName] ) 

Now use measure 

SwitchingMeasure = 
VAR ColName = SELECTEDVALUE ( Dynamic[ColumnName] )
RETURN 

    CALCULATE ( [BaseMeasure], Unpivoted[ColumnName] = ColName ) 

You can register for this online Power BI Training course by Intellipaat to learn Power BI.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Mar 28, 2021 in BI by Chris (11.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.7k questions

32.8k answers

500 comments

109k users

Browse Categories

...