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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Yesterday date

So I am trying to generate a calendar from yesterdar so I tried #date(Date.Year(DateTime.LocalNow()), (Date.Month(DateTime.LocalNow())), [dias]) where dias is a column where I am getting from the day but I need to state the month and year based on yesterdar rather than today since on th 1st of every month I need to display the information of the 30th/ 31st of the last month. "DateTime.Localnow()  -1 " doent work

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous - Try:

Date.AddDays(DateTime.LocalNow(),-1)

 



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

4 REPLIES 4
Anonymous
Not applicable

 Hi, 

@Greg_Deckler your solution works for a similar question I had, however can you please let me know how to remove the time that is returned next to the date? What I see when i use 

 

is 23/12/2021 13:30:17

I would like to remove the hour/minutes/seconds please.

 

Many thanks

 

@Anonymous Just format it as only a date and note a date/time.



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...
CNENFRNL
Community Champion
Community Champion

@Anonymous 

DateTime.LocalNow() - #duration(1,0,0,0)

if you prefer a form of subtraction.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Greg_Deckler
Community Champion
Community Champion

@Anonymous - Try:

Date.AddDays(DateTime.LocalNow(),-1)

 



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 Kudoed Authors