Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

SamePeriodLastYear not working as expected

Hi, im writting to see if any of you can help me with my volumen report.

I am trying to compare the volume of  the year 2020 with the year 2019 with the SamePeriodLastYear measure however the measure is not bringing me the values ​​of 2019 ... the strange thing is that works when i compared the volume of 2019 the measure brings me the values ​​of 2018 ... what may be missing?

 

I think something in the formula may be wrong.. there is just this table

CALCULATE([Volume];SAMEPERIODLASTYEAR('Tabla calendario'[Date]))

 

  • HI Anonymous 

    The problem is that there is a filter in 'Maestro CeCo'[Tipo Material]

    and in the relationship that there is a wrong logic in it.

     

    you could not use "both" between 'Forecast 2019' and 'Tabla calendario', but the relationship is many to many, so you could just adjust the relationship as below:

    Step1:

    Add a dim Year table

    DIM year = SUMMARIZE('Tabla calendario','Tabla calendario'[año])

    Step2:

    Use this dim year table as a bridge table to create a relationship between 'Forecast 2019' and 'Tabla calendario' as below:

     

    Note: cross filter direction between 'Tabla calendario'  and 'Dim year' is "Both'

    Result:

    By the way, for the built-in date hierarchy of power bi, you'd better use [año] field instead of year hierarchy year of [date] field.

     

    and here is sample pbix file, please try it.

     

    Regards,

    Lin

7 Replies