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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

why earlier function error

Hi, 

 

I want to calculate the total number of convid cases by date. however the formula below throws an error. I think it might relates to the language setup of my Power BI or my laptop. however, i don't know how to fix it. 

convid.PNG

 

1 ACCEPTED SOLUTION

OK, you generally don't use EARLIER in a measure unless you are using ADDCOLUMNS.

 

So, the next question, what are you trying to accomplish? If you just do SUM([Total confirmed cases of COVID-19] and you put that in a visual along with your Date column, you should get the total confirmed cases for every date. Is that what you want?

 

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
Greg_Deckler
Community Champion
Community Champion

That's odd, the error message doesn't seem to match. First question, is this supposed to be a measure or a column?

 



Follow on LinkedIn
@ 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!:
DAX For Humans

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

I meant to write a measure. 

 

 

OK, you generally don't use EARLIER in a measure unless you are using ADDCOLUMNS.

 

So, the next question, what are you trying to accomplish? If you just do SUM([Total confirmed cases of COVID-19] and you put that in a visual along with your Date column, you should get the total confirmed cases for every date. Is that what you want?

 

 



Follow on LinkedIn
@ 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!:
DAX For Humans

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

You are right. when I use the earlier function in the column calculation, it works!

 

I also remember the reason behind, ealier function scann the day column line by line to get the current "day" as a filter condition. Therefore it can only be used in column calculation.

 

 

Yes, unless you use ADDCOLUMNS in a measure, then you can use EARLIER when adding a column.

 



Follow on LinkedIn
@ 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!:
DAX For Humans

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

I don't think earlier function is only used in new column. I have seen examples using earlier function to create a measure of sales revenue by product category, and use this measure to create visuals with slicers. 

 

In my case, i want to know how number of crono cases grows from day x to day x+1. Using China and Italy data, it turns out before lockdown, the crono cases increase 30-40% per day, 5 days after lockdown, the increase rate declines. i would like to see if it's the similar case with other countries. therefore i want to create the growth rate measure, track growth rate by days and country in power visual. 

 

Yes, that's why I said generally! 🙂 It can be done, it is just not that common.

 

If I may make a suggestion, I would try something like:

 

 

% Growth = 
  VAR __Date = MAX('Table'[Date])
  VAR __Today = SUM([Total confirmed cases of COVID-19])
  VAR __Yesterday = SUMX(FILTER('Table',REMOVEFILTERS('Table'[Date]),[Date]=(__Date - 1) * 1.),[Total confirmed cases of COVID-19])
RETURN
  DIVIDE(__Today - __Yesterday,__Yesterday,0)

 

You should be able to place that into a visual along with Date.

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors