Forum Discussion
RANKX
Categoria classificada =
VAR TotalSales = CALCULATE(SUM(SalesTable[Sales]))
RETURN
RANKX(
ALL(ProductTable[Category]),
CALCULATE(SUM(SalesTable[Sales])),
,
DESC,
Dense
)
Assuming you have a sales table named 'SalesTable' with a column 'Sales' representing the sales value, and a product table named 'ProductTable' with a column 'Category' representing the product category.
The above code calculates the total sales for all products using the CALCULATE function with the SUM function. Then we use the RANKX function to rank each product category based on total sales, using the CALCULATE function with the SUM function to calculate sales for each category. The ALL function removes all product category filters, so that all categories are ranked based on total sales.
Thank you, This is exactly what I did on my measure. Again, It works fine on a table visual, but as soon as you add a signle KPI card, then add a visual level filter to filter by Category= "Clothes", then the rank is not accurate.