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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply

Find Previous Month and Year from datetime column

Hello all, 

 

I have an issue in finding Previous Month and Year. 

R_DateTime
01/07/2022 12:00:00 AM
01/08/2022 12:00:00 AM
01/09/2022 12:00:AM

 

I have a column called R_DateTime I have to find max month and year and Previous month and year from this column. 

Like CurrentMonth = Sep-2022 

        PreviousMonth = Aug-2022. 

The DAX should be dynamic if months get added later in future. 

 

Help would be much appreciated.

1 ACCEPTED SOLUTION
rsbin
Super User
Super User

@SandhyaGiriraj ,

Hope these two Measures solve your issue:

CurrentMonthYear = FORMAT( MAX(R[R_DateTime]), "mmm-yyyy" )

PreviousMonthYear = FORMAT(EOMONTH( MAX(R[R_DateTime]), -1 ), "mmm-yyyy" )

 

rsbin_0-1667853000882.png

Regards,

View solution in original post

1 REPLY 1
rsbin
Super User
Super User

@SandhyaGiriraj ,

Hope these two Measures solve your issue:

CurrentMonthYear = FORMAT( MAX(R[R_DateTime]), "mmm-yyyy" )

PreviousMonthYear = FORMAT(EOMONTH( MAX(R[R_DateTime]), -1 ), "mmm-yyyy" )

 

rsbin_0-1667853000882.png

Regards,

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.