Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Arul
Super User
Super User

DAX

What is earlier in DAX language?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

consider this data

Label Value
A 1
A 2
B 3
B 4
C 4
C 5

and then compare this calculated columns

Column1 = CALCULATE(SUM('Table'[Value]),ALL('Table'), 'Table'[Label]='Table'[Label])

Column2 = 
CALCULATE(
    SUM('Table'[Value]),
    ALL('Table'), 
    'Table'[Label]=EARLIER('Table'[Label]) --we iterate over Table[Label] comparing it over the evalulation of the column in the filter context outside of CALCULATE
)

Column3 =
VAR CurrentLabel = 'Table'[Label] -- evaluated in the unmodified row specific context
RETURN
CALCULATE(
    SUM('Table'[Value]),
    ALL('Table'), --changes filter context to the whole table
    'Table'[Label]= CurrentLabel 
)

 

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

3 REPLIES 3
Stachu
Community Champion
Community Champion

you can use it to change the filter context of a column to one of its previous states
https://dax.guide/earlier/

https://docs.microsoft.com/en-us/dax/earlier-function-dax

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Can you please explain me with a real time example?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


Stachu
Community Champion
Community Champion

consider this data

Label Value
A 1
A 2
B 3
B 4
C 4
C 5

and then compare this calculated columns

Column1 = CALCULATE(SUM('Table'[Value]),ALL('Table'), 'Table'[Label]='Table'[Label])

Column2 = 
CALCULATE(
    SUM('Table'[Value]),
    ALL('Table'), 
    'Table'[Label]=EARLIER('Table'[Label]) --we iterate over Table[Label] comparing it over the evalulation of the column in the filter context outside of CALCULATE
)

Column3 =
VAR CurrentLabel = 'Table'[Label] -- evaluated in the unmodified row specific context
RETURN
CALCULATE(
    SUM('Table'[Value]),
    ALL('Table'), --changes filter context to the whole table
    'Table'[Label]= CurrentLabel 
)

 

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.