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
PriyankaJhaTheA
Helper II
Helper II

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
Solution Sage
Solution Sage

@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
Solution Sage
Solution Sage

@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
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.

Top Solution Authors