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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Jos13
Helper III
Helper III

Previous Month

Hi Team,

I have the following measure to get year month (YYYYMM) number for the value selected in the date filter.

Current Year Month = SELECTEDVALUE('Date'[YM no])
I used the following measure to find previous year month number.
Prev Year Month =
var CYM=[Current Year Month]
return CALCULATE(MAX('Date'[YM no]),ALLSELECTED('Date'),KEEPFILTERS('Date'[YM no]<CYM))
but the value returned by Prev Year Month is blank.
 
Kindly help
 
scr1.JPG
1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @Jos13 ,

 

We can try to use the following measure to meet your requirement:

 

Prev Year Month =
VAR CYM =
    MIN ( 'Date'[YM no] )
RETURN
    CALCULATE (
        MAX ( 'Date'[YM no] ),
        FILTER (
            ALL ( 'Date' ),
            'Date'[YM no] < CYM
        )
    )

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-lid-msft
Community Support
Community Support

Hi @Jos13 ,

 

We can try to use the following measure to meet your requirement:

 

Prev Year Month =
VAR CYM =
    MIN ( 'Date'[YM no] )
RETURN
    CALCULATE (
        MAX ( 'Date'[YM no] ),
        FILTER (
            ALL ( 'Date' ),
            'Date'[YM no] < CYM
        )
    )

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Community Champion
Community Champion

If time intelligence functions fail you, See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

With date calendar and rime intelligence, you can get that easily. Make sure you move all your month year calc to the calendar table

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
last year MTD Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))

 

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@Jos13 has the above replies helped. if you need more help make me @

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors