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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
BobKoenen
Helper IV
Helper IV

removing filter context for a switch formula

Hi all,

 

I have a sum measure and a RankX measure based on the Sum Measure. Now I want to create a measure which uses the output of the Rankx Measure to change this number in order to be able to create A podium visual with a bar chart. 

My data looks like this:

 

CategorySum of salesRankDesired measure result
A120033
B150012
C130021

 

So If the Rank = 1 then 2, IF rank =2 then 1, IF rank =3 then 3

I Tried to use the following formula but it returns only 2 probably because of the row filter context.

 SWITCH(
Rank,1,2,
 Rank,2,1,
Ranks,3,3))

 
Hope you can help me

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@BobKoenen 

It should work. Did you use correct syntax of SWITCH funtion?

should be 

SWITCH (

TEUE ( ),

Rank,1,2,
 Rank,2,1,
Ranks,3,3)

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Measure = SWITCH([RANK],1,2,2,1,3)

CNENFRNL_0-1655901647663.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

tamerj1
Super User
Super User

@BobKoenen 

It should work. Did you use correct syntax of SWITCH funtion?

should be 

SWITCH (

TEUE ( ),

Rank,1,2,
 Rank,2,1,
Ranks,3,3)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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