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
karun_r
Employee
Employee

How to get the prior year MTD value ?

I am trying to pull the prior year MTD value for each month seperately. This is to calculate YoY for each month and display it in a table.

 

I am trying to use the below measure to get the prior year MTD value but it always returns full month value instead of the MTD one. Any hint on where I am going wrong here ?

 

Formulas that I have tried:

 

May PY 3 = 
VAR Dates = SELECTCOLUMNS(FILTER(Dim_Time,Dim_Time[FiscalMonthName] = "May, 2018"),"Date",[CalendarDate])
RETURN 
CALCULATE (
    SUM ( Fact[Revenue]),
    DATESBETWEEN (
       Dates,
        FIRSTDATE ( DATEADD (Dim_Time[CalendarDate] , -12, MONTH ) ),
        IF (
            MONTH ( MIN (Dim_Time[CalendarDate] ) ) = MONTH ( TODAY () ),
            EDATE ( TODAY (), -12 ),
            LASTDATE ( DATEADD ( Dim_Time[CalendarDate], -12, MONTH ) )
        )
    )
)

 

This one doesn't work at all. It says that DatesBetween will only accept a date reference column.  So I tried my luck with this one

 

May PY 2 = CALCULATE(SUM(Fact[Revenue]),SAMEPERIODLASTYEAR(DATESMTD(Dim_Time[CalendarDate])))

 This measure gives out the full month results instead of the MTD value. From my understanding, it should consider only the MTD dates for the current month and then give the prior year dates because of the SAMEPERIODLASTYEAR function, isn't it ?

1 ACCEPTED SOLUTION

No, but I've got SAMEPERIODLASTYEAR to work after adjusting few other filters on the page level. It was a mistake from my end.

View solution in original post

3 REPLIES 3
Phil_Seamark
Employee
Employee

Hi @karun_r

 

Have you tried PARALLELPERIOD instead of SAMEPERIODLASTYEAR?

 

https://msdn.microsoft.com/en-us/query-bi/dax/parallelperiod-function-dax


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

No, but I've got SAMEPERIODLASTYEAR to work after adjusting few other filters on the page level. It was a mistake from my end.

Hi

 

Can you please let us know what exactly worked for you?

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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