Forum Discussion
atpostdata
3 years agoFrequent Visitor
How to get top5 values based on a field.
To retrieve the top 5 values from each category based on a specific field in Power BI, I used below measure but it giving me all negative records. Top5Negative Records =
CALCULATE(...
- 3 years ago
rubayatyasmin
Community Champion
3 years agoHi, atpostdata thanks for reaching out.
I have tried with your demo data and achieved the result. The way I did it is by creating 3 calculated columns.
1. Rank ASC column
2. Rank DSC column
3. to check whether or not these columns fall under top5
then used a visual level filter where the third columns value is true
sample code for 3 calculated column
1.
Rank Asc =
RANKX(
ALL(Data),
Data[values],
,
ASC,
Skip
)
2.
Rank Desc =
RANKX(
ALL(Data),
Data[values],
,
DESC,
Skip
)
3.
IsInTopBottom5 = IF(Data[Rank Asc] <= 5 || Data[Rank Desc] <= 5, "Yes", "No")
table will look something like
then apply a visual level filter where IsInTopBottom5 is yes