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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ovonel
Post Prodigy
Post Prodigy

How to calculate measure for months -12 to -24 (based on max selected date on filter)

Hi,

 

I have 2 measures, where depending on the date filters selected, I show:

 

Last 12 months:

CALCULATE

(

[Xyz] , DATESINPERIOD (  'Date'[Date] ,  MAX('Date'[Date]) ,  -12 ,  MONTH  )

)

 

 

I need to do the same, but for months -12 to -24.

 

I have tried, but DATEADD doesn’t seem to work with MAX…

 

var dat = MAX('Date'[Date])



RETURN

CALCULATE

(

    [Xyz] ,

    DATESINPERIOD(

            'Date'[Date],   

            DATEADD(dat,-12,MONTH)    ,-24,MONTH)



)

 

 

How can I make the period from -12 to  -24 ?

1 REPLY 1
amitchandak
Super User
Super User

@ovonel , Try like

 

Rolling 12 till last 12 month = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],maxX(Sales, dateadd(Sales[Sales Date],-12,month)),-12,MONTH))

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors