Forum Discussion

ChrisFromOhio's avatar
4 years ago
Solved

SAMEPERIODLASTYEAR But with different end dates

Hello - I want to calculate YOY sales for various companies, but with different end dates. For example:

 

I have Company A sales data from 1/1/22 - 5/31/22, so prior year sales should be from 1/1/21 - 5/31/21.

I have Company B sales data from 1/1/22 - 6/15/22, so prior year sales should be from 1/1/21 - 6/15/21.

I have Company C sales data from 1/1/22 - 5/31/22, so prior year sales should be from 1/1/21 - 5/31/21.

 

I have sales data for companies A, B, and C from 1/1/21 - the dates listed above all in one combined query.

 

However, when I use SAMEPERIODLASTYEAR in my CALCULATE function, I'm getting last year sales for all companies from 1/1/21 - 6/15/21, even though I do not have sales data for companies A and C for 6/1/22 - 6/15/22. Is there a way to only calculate prior year sales for days that I have sales data for this year?

  • ChrisFromOhio , if you view data by the company it should bring only that much

     

    Try if this can help

    sumx(Values(company[company]), Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date])) )

1 Reply

  • ChrisFromOhio , if you view data by the company it should bring only that much

     

    Try if this can help

    sumx(Values(company[company]), Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date])) )