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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
karo
Advocate V
Advocate V

DAX LASTDATE () - how can I fix my formulas

Hi,

 

Could you help me identify why in some cases I am getting (Blank) for Last Snapshot -1? What is my mistake in DAX? 

 

Last Snapshot = LASTDATE('Snapshot Date'[Snapshot Date])
Last Snapshot -1 = DATEADD(LASTDATE('Snapshot Date'[Snapshot Date]),-1,MONTH)
 
Case OK:
karo_0-1667396026671.png

 

Case NOT OK:
 karo_1-1667396092024.png

 

Regards,
Karo
 

 

 

 

 

1 ACCEPTED SOLUTION
karo
Advocate V
Advocate V

Hi @amitchandak , @KNP , @Anonymous ,

 

Thank you for all your help. I have resolved my issue using:

 

Last Snapshot Date = LASTDATE('Snapshot Date'[Snapshot Date])
Last Snapshot Date - 1 = ENDOFMONTH(PREVIOUSMONTH(LASTDATE('Snapshot Date'[Snapshot Date])))
 
Regards,
Karo

View solution in original post

7 REPLIES 7
karo
Advocate V
Advocate V

Hi @amitchandak , @KNP , @Anonymous ,

 

Thank you for all your help. I have resolved my issue using:

 

Last Snapshot Date = LASTDATE('Snapshot Date'[Snapshot Date])
Last Snapshot Date - 1 = ENDOFMONTH(PREVIOUSMONTH(LASTDATE('Snapshot Date'[Snapshot Date])))
 
Regards,
Karo
Anonymous
Not applicable

Hi @karo ,

It's glad to hear that you have resolve the problem. And thanks for sharing the solution here. Could you please mark the helpful post as Answered since it has been resolved? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards

Anonymous
Not applicable

Hi  @karo ,

Whether your problem has been resolved? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards

Anonymous
Not applicable

Hi @karo ,

Please update the formula of measure [Last Snapshot -1] as below and check if you can get the correct result...

Last Snapshot -1 = EOMONTH([Last Snapshot],-1)

yingyinr_0-1667960819455.png

yingyinr_1-1667960849546.png

Best Regards

amitchandak
Super User
Super User

@karo , try like

 

Last Snapshot -1 = date(Year([Last Snapshot]), month([Last Snapshot])-1, day([Last Snapshot]) )

 

dateadd need continuous dates in the table

 

Date as Dateadd - Decoding Date and Calendar 5-5
https://community.powerbi.com/t5/Community-Blog/Date-as-Dateadd-Decoding-Date-and-Calendar-5-5-Power...

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

@amitchandak Thank you for reply, but still this is not the solution. When I am trying DATE() then I am getting even worse results:

 

Last Snapshot = LASTDATE('Snapshot Date'[Snapshot Date])
Last Snapshot -1 = DATEADD(LASTDATE('Snapshot Date'[Snapshot Date]),-1,MONTH)
Last Snapshot -1 (2) = Date(Year([Last Snapshot]),MONTH([Last Snapshot])-1,DAY([Last Snapshot]))
 
karo_0-1667463510015.png

 

 
 

 

I might be wrong but I think @amitchandak was trying to refer to the column, maybe?

LastSnapshotDate =
DATE ( 
    YEAR ( 'Snapshot Date'[Snapshot Date] ), 
    MONTH ( 'Snapshot Date'[Snapshot Date] ) - 1, 
    DAY ( 'Snapshot Date'[Snapshot Date] ) 
)

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.