Forum Discussion

vwiles84's avatar
vwiles84
Helper III
6 years ago
Solved

Prior Year Sales - Filter (Retail comparison)

I have established a connection to a table in SQL that has all of the data I need in my report.  I want to calculate Prior year sales based on a single date filter.  I need the prior year to be the exact day of the week as last year not necessarily the same date.  For example last year from today's date (Tuesday 2/11/2020) is Tuesday 2/12/2019.  In my table, there is daily sales data starting from 2014 up to current.  I have created another date calendar table in Power BI that does a calculation to determine what the last year's date is.  What I cannot get it how to write the calculation to pull in the sum of sales based on the DayLY column in this calendar table. Any ideas?

  • Hi vwiles84 

     

    Sorry for my late reply. I can't check your sample pbix anymore coz it's expired. 

    I created a sample below to calculate the prior date by conditions for your reference:

    Measure = CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),[year]=YEAR(MAX('Table'[Date]))-1&&[weeknum]=WEEKNUM(MAX('Table'[Date]))&&[weekday]=WEEKDAY(MAX('Table'[Date]),2)))

     

    and you can calculate the sales by filter the date=[measure].

    Pbix attached.

     

5 Replies