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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PriyankaJhaTheA
Helper III
Helper III

URGENT!! Ranking measure not working.

Hello Power BI community!Preview

 

Can you help me with the below ranking code? This code is giving me the same ranking for different % of search order columns: 

 

SortingOrderSearchOrder_SingleSelect = 
VAR SelectedProducts =
    {"Search Order (First)",
"Brand First",
"Category First",
"Flavour Variant First",
"Format First",
"Not Answered",
"Nutritional Content First",
"Others First",
"Pack Size First",
"Pack Type First",
"Packaging Design First",
"Price First",
"Product Origin First",
"Promotion First",
"Returnable Packaging First",
"Temperature First",
"Try New First",
"Unit Type First"
}

RETURN
IF(
    max('df_Search Order (First)'[Search Order (First)]) IN SelectedProducts,
    RANKX(
        FILTER(
            ALL('df_Search Order (First)'[Search Order (First)]),
            'df_Search Order (First)'[Search Order (First)] IN SelectedProducts
        ),
        [Ranking SingleSelect],
        ,
        ASC
    ),
    0
)

 


below is a screenshot of the measure - 

PriyankaJhaTheA_0-1709818939869.png


Following are the reference measures used: 

 

 

Category_Occasion_SingleSelect% = 
    [DistinctCount_Category_Occasions_SingleSelect]/
        [TotalSum_Category_Occasion_SingleSelect]
Ranking SingleSelect = 
RANKX(ALL('df_Search Order (First)'[Search Order (First)]), [Category_Occasion_SingleSelect%], , DESC, Dense)

 




@MFelix , @amitchandak , @Ashish_Mathur 

 

 

 
2 ACCEPTED SOLUTIONS

@PriyankaJhaTheA 

I was wondering why cannot you use this pattern 

RANKX( ALLSELECTED('df_Search Order (First)'[Search Order (First)])  , [Category_Occasion_SingleSelect%]) 

  

tharunkumarRTK_0-1709828280185.png


If the post helps please give a thumbs up


If it solves your issue, please accept it as the solution to help the other members find it more quickly.


Tharun

 

View solution in original post

Hi,

I revised your measure to:

Ranking SingleSelect = 
RANKX(ALLSELECTED('df_Search Order (First)'[Search Order (First)]), [Category_Occasion_SingleSelect%], , DESC, Dense)

This also works

Ranking SingleSelect 1 = 
RANK(DENSE,SUMMARIZE(ALLSELECTED('df_Search Order (First)'),'df_Search Order (First)'[Search Order (First)],"A",[Category_Occasion_SingleSelect%]),orderby([A],DESC))

Hope this helps.

Ashish_Mathur_0-1709857199920.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
tharunkumarRTK
Super User
Super User

@PriyankaJhaTheA 

Okay, not sure why you are using two rank functions. Will it be possible for you to share the pbix file with sample data? and expected result.

yeah sure, Here is the link to the sample dashboard: https://drive.google.com/file/d/1_-nOngtU4ZKV_Ju-_km_pm4V-FELqRN6/view?usp=sharing
and here is the expected result: 

PriyankaJhaTheA_0-1709825235119.png

 

Hi,

I revised your measure to:

Ranking SingleSelect = 
RANKX(ALLSELECTED('df_Search Order (First)'[Search Order (First)]), [Category_Occasion_SingleSelect%], , DESC, Dense)

This also works

Ranking SingleSelect 1 = 
RANK(DENSE,SUMMARIZE(ALLSELECTED('df_Search Order (First)'),'df_Search Order (First)'[Search Order (First)],"A",[Category_Occasion_SingleSelect%]),orderby([A],DESC))

Hope this helps.

Ashish_Mathur_0-1709857199920.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks a lot @Ashish_Mathur for the help! 

@PriyankaJhaTheA 

I was wondering why cannot you use this pattern 

RANKX( ALLSELECTED('df_Search Order (First)'[Search Order (First)])  , [Category_Occasion_SingleSelect%]) 

  

tharunkumarRTK_0-1709828280185.png


If the post helps please give a thumbs up


If it solves your issue, please accept it as the solution to help the other members find it more quickly.


Tharun

 

Thanks a lot @tharunkumarRTK @ for the help! 

tharunkumarRTK
Super User
Super User

@PriyankaJhaTheA 

Have you used any other column to sort this column ? if yes then you need to include the sorting column into ALL() incase if you want to remove filters on that column.

'df_Search Order (First)'[Search Order (First)

 


If the post helps please give a thumbs up


If it solves your issue, please accept it as the solution to help the other members find it more quickly.


Tharun

 

Hello @tharunkumarRTK !

 

I'm not sroting 'df_Search Order (First)'[Search Order (First)] column with any other column. I'm not sure why this is happening

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.