Forum Discussion
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
- v-danhe-msftMicrosoft 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:
Regards,
Daniel He
- v-danhe-msftMicrosoft 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