Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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
Solved! Go to Solution.
@PriyankaJhaTheA
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.
@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:
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.
@PriyankaJhaTheA
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
@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
User | Count |
---|---|
57 | |
22 | |
21 | |
19 | |
16 |
User | Count |
---|---|
87 | |
87 | |
52 | |
37 | |
23 |