Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Help with Prior Year

Hi all,   We currently use a prior year Dax that is shown below. We do not use a normal Calendar as we use a financial Calendar for our business, so when we want to see Prior year sales for example...
  • bhanu_gautam's avatar
    2 years ago

    Anonymous , It looks like the DAX measure you are using is causing performance issues due to the way it calculates the prior year sales by iterating over 100 rows.

    Instead of calculating the prior year week dynamically in your measure, you can create a calculated column in your 'Calendar' table that stores the prior year week. This will make your measure more efficient.

     

    PriorYearWeek = 'Calendar'[AFBYearWeek] - 100

     

    Then you can use this calculated column in your measure

    PriorYearSales =
    CALCULATE(
    SUM(Sales_StoreProductDate[SalesValue]),
    FILTER(
    ALL('Calendar'),
    'Calendar'[AFBYearWeek] = MAX('Calendar'[PriorYearWeek])
    )
    )