Forum Discussion
Top product name per category
- 3 years ago
Hello , please give this a try :
TopProduct =
VAR RankingContext = VALUES(DIM_WON_ANALYTICS[Product])
VAR TopProductSales = CALCULATE([Total Sales], TOPN(1, ALL(DIM_WON_ANALYTICS[Product]), [Total Sales]), RankingContext)
RETURN
FIRSTNONBLANK(FILTER(DIM_WON_ANALYTICS, [Total Sales] = TopProductSales), [Product])
////// This measure first calculates the total sales for each product in the context of the category and month, then uses the TOPN function to return the product with the highest sales. It then uses the FILTER function to return the first non-blank product name that matches the sales of the top product.
If it works kindly accept it as a solution
Hello , please give this a try :
TopProduct =
VAR RankingContext = VALUES(DIM_WON_ANALYTICS[Product])
VAR TopProductSales = CALCULATE([Total Sales], TOPN(1, ALL(DIM_WON_ANALYTICS[Product]), [Total Sales]), RankingContext)
RETURN
FIRSTNONBLANK(FILTER(DIM_WON_ANALYTICS, [Total Sales] = TopProductSales), [Product])
////// This measure first calculates the total sales for each product in the context of the category and month, then uses the TOPN function to return the product with the highest sales. It then uses the FILTER function to return the first non-blank product name that matches the sales of the top product.
If it works kindly accept it as a solution