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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors