𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄𝗲𝗿:
You have 2 minutes to solve this Power BI problem.
You have a Sales table with the following columns:
Product
Sales
Create a DAX measure to rank products based on total sales, with the highest-selling product ranked as 1.
𝗠𝗲: Challenge accepted! 💪
Product Rank = RANKX( ALL(Sales[Product]), [Total Sales], , DESC, DENSE )
💡 Explanation:
• RANKX() assigns a rank to each product based on its total sales.
• ALL(Sales) removes the product filter so all products are included in the ranking.
• [Total Sales] is the expression used for ranking.
• DESC ranks the highest sales as Rank 1.
• DENSE ensures there are no gaps in ranking when products have the same sales.[Product]
This challenge tests your understanding of: ✅ RANKX()
✅ ALL()
✅ Ranking in DAX
✅ Filter Context
🎯 Expected Output Example
Product: Laptop | Sales: 75,000 | Rank: 1
Product: Mobile | Sales: 68,000 | Rank: 2
Product: Monitor | Sales: 52,000 | Rank: 3
Product: Keyboard | Sales: 52,000 | Rank: 3
Product: Mouse | Sales: 40,000 | Rank: 4
🚀 Bonus (Rank Within Selected Filters)
Product Rank = RANKX( ALLSELECTED(Sales[Product]), [Total Sales], , DESC, DENSE )
Using ALLSELECTED() makes the ranking dynamic by considering the products visible after slicers and filters are applied.
🚀 Tip for Power BI Job Seekers:
RANKX() is one of the most frequently asked DAX functions. Be comfortable using it for:
• Top N Products
• Customer Ranking
• Employee Performance Ranking
• Regional Sales Ranking
• Dynamic Leaderboards
React with ❤️ for more Power BI interview challenges!