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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
selpaqm
Helper V
Helper V

RANKX with SELECTEDVALUE

Hi,

 

I have a 6 different measure and want to use all of them on rankx with slicer. aim is creating a slicer with names of measures first then using selectedvalue and show top 10 figures on table.

I have created a table as figures and added measure names in to cells.

then created below dax but receiving error as "Special flag is not allowed as an argument number 3 of function 'RANKX'"

Top_10_Rating = 
Var
Selected=IF(SELECTEDVALUE(Figures[Figures])="aaa",[aaa],
IF(SELECTEDVALUE(Figures[Figures])="bbb",[bbb],
IF(SELECTEDVALUE(Figures[Figures])="ccc",[ccc],
IF(SELECTEDVALUE(Figures[Figures])="ddd",[ddd],
IF(SELECTEDVALUE(Figures[Figures])="eee",[eee],
IF(SELECTEDVALUE(Figures[Figures])="fff",[fff],BLANK()))))))
Var
mrank=RANKX(ALL(Table[Name]), Selected,desc)
return
IF(mrank<=10, Selected,BLANK())
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@selpaqm ,

 

Top_10_Rating = 
Var
Selected=IF(SELECTEDVALUE(Figures[Figures])="aaa",[aaa],
IF(SELECTEDVALUE(Figures[Figures])="bbb",[bbb],
IF(SELECTEDVALUE(Figures[Figures])="ccc",[ccc],
IF(SELECTEDVALUE(Figures[Figures])="ddd",[ddd],
IF(SELECTEDVALUE(Figures[Figures])="eee",[eee],
IF(SELECTEDVALUE(Figures[Figures])="fff",[fff],BLANK()))))))
Var
mrank=RANKX(ALL(Table[Name]), Selected,,desc)
return
IF(mrank<=10, Selected,BLANK())

 

One addition is required.

 

Also, my advice would create rank measures and then select then based on selection.

in place [aaa] use Rank on aaa in the formula

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@selpaqm ,

 

Top_10_Rating = 
Var
Selected=IF(SELECTEDVALUE(Figures[Figures])="aaa",[aaa],
IF(SELECTEDVALUE(Figures[Figures])="bbb",[bbb],
IF(SELECTEDVALUE(Figures[Figures])="ccc",[ccc],
IF(SELECTEDVALUE(Figures[Figures])="ddd",[ddd],
IF(SELECTEDVALUE(Figures[Figures])="eee",[eee],
IF(SELECTEDVALUE(Figures[Figures])="fff",[fff],BLANK()))))))
Var
mrank=RANKX(ALL(Table[Name]), Selected,,desc)
return
IF(mrank<=10, Selected,BLANK())

 

One addition is required.

 

Also, my advice would create rank measures and then select then based on selection.

in place [aaa] use Rank on aaa in the formula

@amitchandak can you give me an example becuase table gone crazy waiting ages to monitor one figure.

Just skipping one comma takes 1 hour. thanks @amitchandak 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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