Forum Discussion
Top N from the column
- 4 years ago
Hi, Anonymous
Please try the following methods. You can solve it directly with Dax without creating indexes in the power query.
Measure:
Count name = CALCULATE ( COUNT ( Data[TotalReasons.Name] ), FILTER ( ALL ( Data ), [TotalReasons.Name] = SELECTEDVALUE ( Data[TotalReasons.Name] ) ) )Count reason = CALCULATE ( COUNT ( Data[Reason] ), FILTER ( ALL ( Data ), [Reason] = SELECTEDVALUE ( Data[Reason] ) ) )Rank name = RANKX(ALLSELECTED(Data[TotalReasons.Name]),[Count name],,DESC)Top name = IF([Rank name]<=2,1,0)Put the measure of Top name into the name's view and set it equal to 1.
Is this the result you want for Top 2 name?
Rank reason = RANKX(ALLSELECTED(Data[Reason]),[Count reason],,DESC)Top reason = IF([Rank reason]<=5,1,0)Is this the result you want for Top 5 reason?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, Anonymous
Please try the following methods. You can solve it directly with Dax without creating indexes in the power query.
Measure:
Count name =
CALCULATE (
COUNT ( Data[TotalReasons.Name] ),
FILTER (
ALL ( Data ),
[TotalReasons.Name] = SELECTEDVALUE ( Data[TotalReasons.Name] )
)
)
Count reason =
CALCULATE (
COUNT ( Data[Reason] ),
FILTER ( ALL ( Data ), [Reason] = SELECTEDVALUE ( Data[Reason] ) )
)
Rank name = RANKX(ALLSELECTED(Data[TotalReasons.Name]),[Count name],,DESC)Top name = IF([Rank name]<=2,1,0)
Put the measure of Top name into the name's view and set it equal to 1.
Is this the result you want for Top 2 name?
Rank reason = RANKX(ALLSELECTED(Data[Reason]),[Count reason],,DESC)Top reason = IF([Rank reason]<=5,1,0)
Is this the result you want for Top 5 reason?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.