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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
GoingIncognito
Advocate III
Advocate III

Dateadd lastdate from fact table

Hi, all ya!

Question: I need to do get a spesific date from fact table that doesn't have all the dates, how do I accomplish this? I do have a calendar table but the max(calendar[date]) doesn't equal max(fact[date]). So I would need to go back in time from the date that is max(fact[date]).
The thing is I got 

CALCULATE( SUM(FACT[VALUE]),  DATEADD(LASTDATE(FACT[PDATE]), -3, MONTH) ) working just fine, BUT
CALCULATE( SUM(FACT[VALUE]),  DATEADD(LASTDATE(FACT[PDATE]), -6, MONTH) ) gives me a blank. I'm guessing this is due to fact table missing that date?

 

Thank you all!

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi  @GoingIncognito 

First, DATEADD is a Time-intelligence function, so you'd better add a dim date table in your model for calculation.

https://radacad.com/do-you-need-a-date-dimension

Second, for "I'm guessing this is due to fact table missing that date", this means that there is no data that before 6 months of LASTDATE(FACT[PDATE]).

For example: if current row context of LASTDATE(FACT[PDATE]) is 7/19/2019, when there is no data in 1/19/2019, it will return blank.

Third, "how do I get the last date of that month?", you could try this formula

EOMONTH(LASTDATE('FACT'[PDATE]),0)

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi  @GoingIncognito 

First, DATEADD is a Time-intelligence function, so you'd better add a dim date table in your model for calculation.

https://radacad.com/do-you-need-a-date-dimension

Second, for "I'm guessing this is due to fact table missing that date", this means that there is no data that before 6 months of LASTDATE(FACT[PDATE]).

For example: if current row context of LASTDATE(FACT[PDATE]) is 7/19/2019, when there is no data in 1/19/2019, it will return blank.

Third, "how do I get the last date of that month?", you could try this formula

EOMONTH(LASTDATE('FACT'[PDATE]),0)

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

If your date is joined is date table, use date filter on date table. Yes if there is no date in date table or no data in fact this will not work.

 

Example

CALCULATE(SUM(Sales[Sales Amount]),(dateadd('Date'[Date],-1,MONTH)))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Additional question, how do I get the last date of that month? I can't wrap all that in a EOMONTH() ?

Anonymous
Not applicable

Your guess is correct. 

Perhaps appending the date table with the missing dates to solve it, if your report is build this way. 

A calculated table might come in handy, you can dax a CALENDER function with 

DATEADD(LASTDATE(FACT[PDATE]), -6, MONTH), as start date and 

DATEADD(LASTDATE(FACT[PDATE]), +3, MONTH) as end date. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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