Forum Discussion

hidenseek9's avatar
hidenseek9
Icon for Post Patron rankPost Patron
8 years ago
Solved

parallelperiod DAX not working

Hello Power BI Community,

 

I am having an issue with ParallelPeriod DAX.

I have been using ParallelPeriod function for a while and

this is the first time that the function is not returning my desired result.

Hope you will be able to provide me a solution.

 

Basically, I want to calculate

1) current year spending

2) last year spending

 

Here is how I am calculating above.

1)

CY Spend = CALCULATE(SUM('YTD + YTG'[Amount]))

 

2)

LY Spend = CALCULATE(SUM('YTD + YTG'[Amount]),PARALLELPERIOD('Calendar'[Date].[Date],-12,MONTH))

 

I have created a relationship between "YTD+YTG" and "Calendar" data.

Both dataset contains date in date format.

 

Problems:

1) CY spend returns the number I am looking for, while LY spend does not.

 

 

 

2) When I select 2016 period in the timeline visuals, CY spend returns the right value and somehow LY spend returns the same value also. Please see below.

 

 

 

Do you have any idea why this happens and what the solution should be?

 

Many thanks,

 

H

  • hidenseek9

     

    ParallelPeriod() will already return full periods. Since you may select at different granularity, I suggest you use SAMEPERIODLASTYEAR or DATEADD. 

     

    LY Spend =
    CALCULATE (
        SUM ( 'YTD + YTG'[Amount] ),
        SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
    )

    Regards,

1 Reply

  • v-sihou-msft's avatar
    v-sihou-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    hidenseek9

     

    ParallelPeriod() will already return full periods. Since you may select at different granularity, I suggest you use SAMEPERIODLASTYEAR or DATEADD. 

     

    LY Spend =
    CALCULATE (
        SUM ( 'YTD + YTG'[Amount] ),
        SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
    )

    Regards,