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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Velvetine27
Helper I
Helper I

Display last month in MMM-YY format

Hi,

 

I'm looking for a way to display last month in dax. I've come up with this dax :

CALCULATE(MAX('CalendarTable'[YearMonth]),DATEADD(CalendarTable[Date],-1,MONTH))
 
it works if we select single month. But for some reason when we select multiple months it still shows the max month.
 
Appreciate any help here. 
 
Thanks !
2 REPLIES 2
AjithPrasath
Resolver II
Resolver II

@Velvetine27 ,

 

Use the following code:

LAST_MONTH = 
VAR SelectedMonths = VALUES('CalendarTable'[YearMonth])
RETURN
    CALCULATE(MAX('CalendarTable'[YearMonth]), DATEADD('CalendarTable'[Date], -1, MONTH), SelectedMonths)

Please accept this as solution, if you got your answer and give kudos

Hi, 

 

Thanks for the answer given but unfortunately it doesn't work. When I select all months it doesn't seem to be displaying the correct month, and when i select one month it just displays blank.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.