0
0
Power BIbi_tool~20 mins

EARLIER for row context in Power BI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
EARLIER Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
dax_lod_result
intermediate
2:00remaining
Calculate the rank of sales per product category using EARLIER

You have a table Sales with columns ProductCategory and SalesAmount. You want to create a calculated column CategoryRank that ranks each sale within its product category by sales amount, highest first.

Which DAX formula correctly uses EARLIER to achieve this?

ACategoryRank = COUNTROWS(FILTER(Sales, Sales[ProductCategory] = EARLIER(Sales[ProductCategory]) && Sales[SalesAmount] >= EARLIER(Sales[SalesAmount])))
BCategoryRank = RANKX(FILTER(Sales, Sales[ProductCategory] = EARLIER(Sales[ProductCategory])), Sales[SalesAmount], , DESC)
CCategoryRank = COUNTROWS(FILTER(Sales, Sales[ProductCategory] = Sales[ProductCategory] && Sales[SalesAmount] >= Sales[SalesAmount]))
DCategoryRank = COUNTROWS(FILTER(Sales, Sales[ProductCategory] = EARLIER(Sales[ProductCategory]) && Sales[SalesAmount] <= EARLIER(Sales[SalesAmount])))
Attempts:
2 left
💡 Hint

Remember, EARLIER refers to the current row's value in a nested row context.

🧠 Conceptual
intermediate
1:30remaining
Understanding EARLIER in nested row contexts

In DAX, what does the EARLIER function do when used inside nested row contexts?

A<p>It returns the value of the column from the outer row context.</p>
B<p>It returns the value of the column from the current row context only.</p>
C<p>It creates a new row context for the calculation.</p>
D<p>It aggregates values across all rows ignoring filters.</p>
Attempts:
2 left
💡 Hint

Think about how nested loops work in programming.

🔧 Formula Fix
advanced
2:00remaining
Identify the error in this EARLIER usage

Consider this calculated column formula:

Rank = COUNTROWS(FILTER(Sales, Sales[ProductCategory] = EARLIER(Sales[ProductCategory]) && Sales[SalesAmount] > Sales[SalesAmount]))

What error or issue will this formula cause?

AIt will cause a syntax error due to missing ELSE in EARLIER.
BIt will return the correct rank without errors.
CIt will always return zero because the filter condition compares the same column without EARLIER on the right side.
DIt will cause a type error because EARLIER cannot be used in FILTER.
Attempts:
2 left
💡 Hint

Check how the comparison is made inside the FILTER.

🎯 Scenario
advanced
2:30remaining
Use EARLIER to calculate cumulative sales per customer

You have a Sales table with columns CustomerID, OrderDate, and SalesAmount. You want to add a calculated column CumulativeSales that shows the total sales amount for each customer up to and including the current order date.

Which DAX formula correctly uses EARLIER to calculate this cumulative sales?

ACumulativeSales = CALCULATE(SUM(Sales[SalesAmount]), Sales[CustomerID] = EARLIER(Sales[CustomerID]) && Sales[OrderDate] <= EARLIER(Sales[OrderDate]))
BCumulativeSales = SUM(Sales[SalesAmount]) + EARLIER(Sales[SalesAmount])
CCumulativeSales = SUMX(FILTER(Sales, Sales[CustomerID] = Sales[CustomerID] && Sales[OrderDate] <= Sales[OrderDate]), Sales[SalesAmount])
DCumulativeSales = CALCULATE(SUM(Sales[SalesAmount]), FILTER(Sales, Sales[CustomerID] = EARLIER(Sales[CustomerID]) && Sales[OrderDate] <= EARLIER(Sales[OrderDate])))
Attempts:
2 left
💡 Hint

Use FILTER inside CALCULATE with EARLIER to compare current row values.

visualization
expert
3:00remaining
Visualize sales rank per category using EARLIER

You created a calculated column CategoryRank using EARLIER to rank sales within each product category. You want to build a Power BI report page that clearly shows:

  • Product categories on the Y-axis
  • Sales amounts as bars
  • CategoryRank as data labels on each bar

Which visualization and settings best follow best practices for clarity and accessibility?

AUse a pie chart showing SalesAmount by ProductCategory and add CategoryRank as legend. Use multiple bright colors without checking contrast.
BUse a clustered bar chart with ProductCategory on Y-axis, SalesAmount on X-axis, and enable data labels showing CategoryRank. Use high contrast colors and add alt text describing the chart.
CUse a stacked column chart with ProductCategory on X-axis, SalesAmount stacked by CategoryRank, and no data labels. Use default colors.
DUse a table visual listing ProductCategory, SalesAmount, and CategoryRank with no conditional formatting or accessibility features.
Attempts:
2 left
💡 Hint

Think about which chart type best shows ranking and sales amount clearly.