0
0
Power BIbi_tool~10 mins

EARLIER for row context in Power BI - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

Sales data for employees with their departments and sales amounts.

CellValue
A1Employee
B1Department
C1Sales
A2John
B2Electronics
C21000
A3Jane
B3Electronics
C31500
A4Bill
B4Clothing
C4800
A5Mary
B5Clothing
C51200
Formula Trace
TotalDeptSales = CALCULATE(SUM(Sales[Sales]), FILTER(Sales, Sales[Department] = EARLIER(Sales[Department])))
Step 1: EARLIER(Sales[Department]) for row 2 (John)
Step 2: FILTER(Sales, Sales[Department] = "Electronics")
Step 3: SUM(Sales[Sales]) over filtered rows
Step 4: TotalDeptSales for John = 2500
Step 5: Repeat for row 4 (Bill)
Step 6: FILTER(Sales, Sales[Department] = "Clothing")
Step 7: SUM(Sales[Sales]) over filtered rows
Step 8: TotalDeptSales for Bill = 2000
Cell Reference Map
   A          B            C
1 Employee  Department   Sales
2 John      Electronics  1000
3 Jane      Electronics  1500
4 Bill      Clothing     800
5 Mary      Clothing     1200

Arrows:
- EARLIER references current row's Department in column B
- FILTER uses Department column B to filter rows
- SUM uses Sales column C to sum filtered rows
The formula uses the Department column (B) for EARLIER and FILTER, and Sales column (C) for summing.
Result
   A          B            C       D
1 Employee  Department   Sales  TotalDeptSales
2 John      Electronics  1000   2500
3 Jane      Electronics  1500   2500
4 Bill      Clothing     800    2000
5 Mary      Clothing     1200   2000
The TotalDeptSales column shows the sum of sales for each employee's department, calculated using EARLIER to keep row context.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does EARLIER(Sales[Department]) return when evaluating row 3 (Jane)?
A"Clothing"
B"Electronics"
C1500
DRow number 3
Key Result
EARLIER returns the current row's column value to use inside a FILTER for row context comparison.