Hi @Eric,
Thanks for providing a sample file
Can you see if this works for you.
Top5 By Country/City =
VAR TopFiltered =
CALCULATETABLE(
GENERATE(
VALUES( Location[County] ),
TOPN(
5,
CALCULATETABLE( VALUES ( Location[City] ) ),
[Total Profits]
)
),
ALLSELECTED()
)
RETURN
IF( NOT( ISINSCOPE( Location[City] )), [Total Profits],
CALCULATE( [Total Profits],
KEEPFILTERS ( TopFiltered )
)
)
Here’s your sample file. eDNA - Top5 Country by City.pbix (502.8 KB)
I hope this is helpful.