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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
win_anthony
Resolver III
Resolver III

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. 

1 ACCEPTED SOLUTION

@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" )

 

View solution in original post

3 REPLIES 3
Anonymous
Not 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.

@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" )

 

Anonymous
Not applicable

Cool! Didn't know that function existed! Thanks for sharing!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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