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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tslyonsnj
Frequent Visitor

My use of EARLIER the determine a prior value is not working

I'm trying to develop a pct change in a value row to row, but am stuck getting the prior value of my field.  I've looked at many of the similar threads in this community, and cannot identify where my code is not matching those examples.  I'd appreciate having a more experienced set of eyes on it, if someone's willing.  Thanks.

I'm interested in the % change in field "Tot", which is the sum of Columns "At Minimum Wage" and "Below Minimum Wage".

Here's my code to capture the prior value of "Tot":

PrevRowTot =
CALCULATE(
MAX('Minimum Wage'[Tot]),
FILTER('Minimum Wage','Minimum Wage'[Year]=EARLIER('Minimum Wage'[PrevYear]))
 

I've tried SUM, MIN, and MAX to see if I can determine any pattern in the resultant change in the values returned, but to no avail, and none of them match the prior value of "Tot".

Being kind of new, I'm not sure how to share my pbix, but will be happy to folllow instruction.  Thanks once again.

 

 

 

 

 

1 ACCEPTED SOLUTION

As a matter of fact @Anonymous ...

 

@tslyonsnj - Your use of EARLIER was brilliant! You just need MORE EARLIER!!

 

PrevRowTot = 
    CALCULATE(
        MAX('Minimum Wage'[Tot]),
        FILTER('Minimum Wage','Minimum Wage'[Year]=EARLIER('Minimum Wage'[PrevYear]) && [State]=EARLIER('Minimum Wage'[State]))
)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Best way is to put your PBIX on OneDrive or Box and share. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks for responding.  I will read your referenced post but have saved my pbix on a shared OneDrive folder:

https://1drv.ms/u/s!AlUz3UOkp9Gi83jtVmkUgaHfta-D?e=wQVnUg

 

Thanks again.

As a matter of fact @Anonymous ...

 

@tslyonsnj - Your use of EARLIER was brilliant! You just need MORE EARLIER!!

 

PrevRowTot = 
    CALCULATE(
        MAX('Minimum Wage'[Tot]),
        FILTER('Minimum Wage','Minimum Wage'[Year]=EARLIER('Minimum Wage'[PrevYear]) && [State]=EARLIER('Minimum Wage'[State]))
)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

aaahhh..hahaha.... thanks so much.  As soon as I saw your response it all fell into place.  I'm learning to think in terms of filters, but hadn't thought through the impact of State as an additional dimension.  I had been wondering what I could have done better from a troubleshooting perspective, and the answer is to verify that I've considered all potential contributors to the filter context.

 

Thanks again @Greg_Deckler !!

 

btw... one of life's pleasant little ironies that the solution did indeed involve more EARLIER...  🙂 

No worries, DAX is easy to learn but difficult to master. Takes a while to learn how to "Think DAX"!! 🙂


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler.

It's a problem with EARLIER. You should be able to help him :))) I can't understand why it does not work. After all, you say that...

"EARLIER is the greatest DAX function of all time. If you can't solve your calculation problem, just use EARLIER. Works every time.".

Why then does it not work if you say that it works every time, Greg?

Best
D

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors