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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
slyfox
Helper II
Helper II

Previous month date

Hello,

 

Found a formula at daxpattern for the previous month date

 

 

PM Date =
CALCULATE (
MAX ( D_Date[DATE_Date] ),
ALL ( D_Date ),
FILTER (
ALL ( D_Date[DATE_DayNumberInMonth] ),
D_Date[DATE_DayNumberInMonth] <= EARLIER ( D_Date[DATE_DayNumberInMonth] )
|| EARLIER(D_Date[DATE_DayNumberInMonth] ) = EARLIER ( D_Date[DaysInMonth] )
),
FILTER (
ALL ( D_Date[DATE_MonthNumber] ),
D_Date[DATE_MonthNumber]
= EARLIER ( D_Date[DATE_MonthNumber] ) - 1
)
)

 

but 

 

for some reasons formula return date from the next year instead of current.

day numer and month name is correct.

Why year is a different ?

2 REPLIES 2
v-danhe-msft
Employee
Employee

Hi @slyfox

could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-danhe-msft
Employee
Employee

Hi @slyfox,

Based on my test, you could try this dax formula:

PM = DATE(YEAR('D-Date'[date]),MONTH('D-Date'[date])-1,DAY('D-Date'[date]))

Result:

1.PNG

 

Regards,

Daniel He

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.