Forum Discussion
Sort the given top 5
Hello Community,
In the Pbi Below, I select Category from the slicer, to show the Subcategory by Value in the visual.
I would like to add a measure (to be a column in the table visual), that sort in every selection I make from mentionning the subcategories from 1 to 5 by the biggest value.
Thank you in advance.
- Anonymous1 year ago
Hi Anonymous ,
Please try this:
Ranking = IF( HASONEVALUE('Table'[Subcategory]), RANKX(ALLSELECTED('Table'[Subcategory]), CALCULATE(SUM('Table'[value])),,DESC,Dense) )Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
2 Replies
- LaxmanjatothResolver I
SubcategoryRank =
RANKX(
FILTER(
ALL(Skills[Subcategory]), // Ensure that the filtering only happens within the current Category selection
Skills[Category] = SELECTEDVALUE(Skills[Category]) // Keeps the rank within the selected Category
),
[ValueMeasure], // The measure to rank by (e.g., sales, quantity, etc.)
, DESC, // Sort in descending order (highest value gets rank 1)
Dense // Ties will be assigned the same rank
)
SubcategoryRank =
RANKX(
FILTER(
ALL(Skills[Subcategory]), // Ensure that the filtering only happens within the current Category selection
Skills[Category] = SELECTEDVALUE(Skills[Category]) // Keeps the rank within the selected Category
),
[ValueMeasure], // The measure to rank by (e.g., sales, quantity, etc.)
, DESC, // Sort in descending order (highest value gets rank 1)
Dense // Ties will be assigned the same rank
) - AnonymousNot applicable
Hi Anonymous ,
Please try this:
Ranking = IF( HASONEVALUE('Table'[Subcategory]), RANKX(ALLSELECTED('Table'[Subcategory]), CALCULATE(SUM('Table'[value])),,DESC,Dense) )Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum