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
Anonymous
Not applicable

DAX HELP

I want a column for showing day of last month. But dax is showing data in a different way.

CURRDAYPREVMONTH = DATE(YEAR(ACX_Dates[Date]), MONTH(ACX_Dates[Date])-1, DAY(ACX_Dates[Date]))

 

ACTUAL  
REPORTDATECURRDAYPREVMONTH 
28-03-201728-02-2017 
29-03-201701-03-2017 
30-03-201702-03-2017 
31-03-201703-03-2017 
   
EXPECTED  
REPORTDATECURRDAYPREVMONTH 
29-03-201728-02-2017 
30-03-201728-02-2017 
31-03-201728-02-2017 
1 ACCEPTED SOLUTION

Hacky, but you could always do this:

Column 2 =
IF(DAY([REPORTDATE]) > DAY(EOMONTH([REPORTDATE],-1)),
DATE(YEAR([REPORTDATE]),MONTH([REPORTDATE])-1,DAY(EOMONTH([REPORTDATE],-1))),
DATE(YEAR([REPORTDATE]),MONTH([REPORTDATE])-1,DAY([REPORTDATE]))
)


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
amitchandak
Super User
Super User

@Anonymous 

Try like

new column = dateadd([REPORTDATE],-1,month)

Or
new column =date(year([REPORTDATE]),month([REPORTDATE])-1,day([REPORTDATE]))

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
Anonymous
Not applicable

Already used this same formula, result is different.

Hacky, but you could always do this:

Column 2 =
IF(DAY([REPORTDATE]) > DAY(EOMONTH([REPORTDATE],-1)),
DATE(YEAR([REPORTDATE]),MONTH([REPORTDATE])-1,DAY(EOMONTH([REPORTDATE],-1))),
DATE(YEAR([REPORTDATE]),MONTH([REPORTDATE])-1,DAY([REPORTDATE]))
)


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

Thanks a lot Greg. It worked for me.

I need one more help

 

I want to calculate current Fiscal Year End Date (April - March)

Suppose for Today, Fiscal year end date should be 31-03-2021

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.