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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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

@Anonymous 

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

@Anonymous 

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.