TGViewer
Data Analytics Data Analytics @sqlspecialist ยท 111K subscribers
Post #2961 6.64K
๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„๐—ฒ๐—ฟ:

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!
  • โค 12
More from @sqlspecialist
  1. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  2. Oct 7, 2026๐Ÿ“Š Kandinsky 6.0 Video: AI-Powered Content Creation for Analysts The new Kandinsky 6.0 Vidโ€ฆ
  3. Oct 7, 2026Alternatively, depending on the Excel version and requirement, I could use functions suchโ€ฆ
  4. Oct 7, 2026๐Ÿ“Š Data Analyst Interview Series โ€” Part 5 Guys, let's continue our Data Analyst Interviewโ€ฆ
  5. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  6. Oct 7, 2026๐Ÿ”Ÿ What is the difference between UNION and JOIN? Sample Answer: "JOIN combines columns frโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’