Hint: Number of rows is always first in TOPN syntax [OK]
Common Mistakes:
Swapping table and number_of_rows arguments
Placing order_by_column before table
Omitting the order argument
3. Given the table Sales with columns Product and Revenue, what does this DAX expression return?
TOPN(2, Sales, Sales[Revenue], DESC)
medium
A. The two products with the highest revenue.
B. The two products with the lowest revenue.
C. All products sorted by revenue descending.
D. An error because TOPN needs ASC order.
Solution
Step 1: Analyze the TOPN parameters
TOPN(2, Sales, Sales[Revenue], DESC) means return 2 rows from Sales table sorted by Revenue in descending order.
Step 2: Understand sorting order effect
Descending order means highest values come first, so it returns top 2 products with highest revenue.
Final Answer:
The two products with the highest revenue. -> Option A
Quick Check:
TOPN with DESC = top highest values [OK]
Hint: DESC means highest values first in TOPN [OK]
Common Mistakes:
Confusing DESC with ASC order
Thinking TOPN returns all rows sorted
Assuming TOPN returns lowest values by default
4. Identify the error in this DAX expression:
TOPN(3, Sales)
medium
A. Table name should be in quotes.
B. The number of rows should be last argument.
C. Missing the order_by_column argument.
D. Revenue column cannot be used in TOPN.
Solution
Step 1: Check TOPN function arguments
TOPN requires (at minimum) three arguments: number_of_rows, table, order_by_column [, order (ASC or DESC)].
Step 2: Identify missing argument
The expression lacks the order_by_column argument, which is mandatory to specify the column for sorting.
Final Answer:
Missing the order_by_column argument. -> Option C
Quick Check:
TOPN needs order_by_column [OK]
Hint: Always include order_by_column in TOPN [OK]
Common Mistakes:
Omitting order_by_column argument
Putting number_of_rows last
Using quotes around table names
5. You want to create a measure that shows the total revenue of the top 3 products by revenue. Which DAX expression correctly uses TOPN to achieve this?
hard
A. CALCULATE(SUM(Sales[Revenue]), TOPN(3, Sales, DESC))
B. SUMX(TOPN(3, Sales, Sales[Revenue], DESC), Sales[Revenue])
C. SUMX(FILTER(Sales, Sales[Revenue] >= TOPN(3, Sales, Sales[Revenue], DESC)), Sales[Revenue])
D. CALCULATE(TOPN(3, Sales, Sales[Revenue], DESC), SUM(Sales[Revenue]))
Solution
Step 1: Understand the goal
You want to sum revenue only for the top 3 products by revenue.
Step 2: Analyze each option
CALCULATE(SUM(Sales[Revenue]), TOPN(3, Sales, DESC)) has invalid TOPN syntax (missing order_by_column). SUMX(TOPN(3, Sales, Sales[Revenue], DESC), Sales[Revenue]) uses SUMX over TOPN table, correctly summing revenue of top 3 rows. SUMX(FILTER(Sales, Sales[Revenue] >= TOPN(3, Sales, Sales[Revenue], DESC)), Sales[Revenue]) misuses FILTER with TOPN inside condition, which is invalid. CALCULATE(TOPN(3, Sales, Sales[Revenue], DESC), SUM(Sales[Revenue])) misplaces SUM inside CALCULATE with TOPN, causing syntax error.
Final Answer:
SUMX(TOPN(3, Sales, Sales[Revenue], DESC), Sales[Revenue]) -> Option B
Quick Check:
SUMX over TOPN table sums top rows [OK]
Hint: Use SUMX over TOPN to sum top rows [OK]
Common Mistakes:
Using TOPN directly inside CALCULATE filter
Misusing FILTER with TOPN in condition
Putting aggregation inside CALCULATE incorrectly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.