DAX RANKX Within Group

May 2024 ยท 1 minute read

I have a table called CarSales with the following sample data:

1

I already have a measure that ranks all Brands by sales:

Rank = RANKX(ALL('CarSales'[Brand]),[NetSales])

However, I need another measure/column **"Rank(Country)" ** which ranks the Brands within the Country group (without having to display the Country group in the table)

Thanks

1

1 Answer

Try the following measure:

= VAR ThisCountry = MIN( CarSales[Country] ) RETURN RANKX( FILTER( ALLSELECTED( CarSales ), 'CarSales'[Country] = ThisCountry ), [NetSales] ) 

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobm5rYWWGdn6OnZixZaKWu6zEjLCgraCZo3qovs6upw%3D%3D