Forum Discussion
Creating TopN with two levels
- 10 years ago
Hi there,
Here is how I would do it - I assume you're ranking using a measure.
Change [Your Measure] to the measure used for ranking and YourTable to the appropriate table name.
Your Measure for Top 10 Countries Per Continent = CALCULATE ( [Your Measure], KEEPFILTERS ( GENERATE ( VALUES ( YourTable[Continent] ), TOPN ( 10, ALL ( YourTable[Country] ), [Your Measure] ) ) ) )You could also do it this way if your measure can be summed by Continent:
Your Measure for Top 10 Countries Per Continent v2 = SUMX ( VALUES ( YourTable[Continent] ), CALCULATE ( [Your Measure], TOPN ( 10, ALL ( YourTable[Country] ), [Your Measure] ), VALUES ( YourTable[Country] ) ) )If you just want to display the Countries but not the measure itself, you can use a Visual Level Filter on this measure to nonblank.
Hi there,
Here is how I would do it - I assume you're ranking using a measure.
Change [Your Measure] to the measure used for ranking and YourTable to the appropriate table name.
Your Measure for Top 10 Countries Per Continent =
CALCULATE (
[Your Measure],
KEEPFILTERS (
GENERATE (
VALUES ( YourTable[Continent] ),
TOPN ( 10, ALL ( YourTable[Country] ), [Your Measure] )
)
)
)
You could also do it this way if your measure can be summed by Continent:
Your Measure for Top 10 Countries Per Continent v2 =
SUMX (
VALUES ( YourTable[Continent] ),
CALCULATE (
[Your Measure],
TOPN ( 10, ALL ( YourTable[Country] ), [Your Measure] ),
VALUES ( YourTable[Country] )
)
)
If you just want to display the Countries but not the measure itself, you can use a Visual Level Filter on this measure to nonblank.
This is wonderful! Works perfectly! Thanks :manhappy: