Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

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 - 


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 

 

 

 
  • Anonymous 

    I was wondering why cannot you use this pattern 

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

      


    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

     

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

     

8 Replies

  • Anonymous 

    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

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      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

  • Anonymous 

    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.

      • tharunkumarRTK's avatar
        tharunkumarRTK
        Icon for Super User rankSuper User

        Anonymous 

        I was wondering why cannot you use this pattern 

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

          


        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