Forum Discussion
Format Previous Month Text into KPI
I am trying to display the previous month's text into a measure which will be displayed into a KPI. The odd part is that when I use "Month( Today() ) -1" it will give me an output of "Jan 1900". The goal is to have an output of "May 2021". Any advice on how I am able to write a measure that will give me an output of the previous Month and Year? Below is my current DAX + current/expected output.
Previous Month's KPI Card =
VAR Previous_Month = [Previous Month's Count]
RETURN
SWITCH( TRUE(),
Previous_Month >= 0, "Previous Month's Alerts: " & FORMAT( MONTH( TODAY() ) -1, "MMM YYYY" )
)
Current Output = "Previous Month's Alerts: Jan 1900"
Expected Output = "Previous Month's Alerts: May 2021"
Any advice is greatly appreciated.
- Anonymous5 years ago
Anonymous thank you so much for the support. I actually found a solution that worked best for me: EDATE( Today(), -1)
FORMAT( EDATE( TODAY(), -1 ), "MMM YYYY" )
3 Replies
- AnonymousNot applicable
If you have a date table use the date column instead of "-1". When you use MONTH function it calculates dates as numbers and then it formats it.
You could use PARALLELPERIOD, DATEADD or PREVIOUSMONTH as alternatives as well if you have a date column.
- AnonymousNot applicable
Anonymous thank you so much for the support. I actually found a solution that worked best for me: EDATE( Today(), -1)
FORMAT( EDATE( TODAY(), -1 ), "MMM YYYY" )- AnonymousNot applicable
Cool! Didn't know that function existed! Thanks for sharing!