Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply

Prior Year Sales Not Working with Summarize Function

Hello!

 

I'm looking to create a table that shows each of our stores sales by week and year. I am having issues when using the summarize function, however. I'm sure I'm doing something obviosly wrong but I haven't been able to determine a solution. We use a retail calendar so my calculate functions must use leverage the week and year fields.

 

The real end goal is to be able to pull current year sales if they had sales in sales 1PY or 2PY so we can analyze Same Store Sales with a CY sales that is on an apples to apples basis.

 

Here is my code

 

Sales PY = 

var Sales_2PY =  CALCULATE(
                SUM('Daily Reporting'[Total Dine In Sales])
                ,DATEADD('Date'[Date],-364*2,DAY))
var Sales_1PY =  CALCULATE(
                SUM('Daily Reporting'[Total Dine In Sales])
                ,DATEADD('Date'[Date],-364,DAY))

Return

SUMMARIZE(
            'Daily Reporting'
            ,'Daily Reporting'[UnitName]
            ,'Daily Reporting'[State]
            ,'Daily Reporting'[Week Number]    
            ,'Daily Reporting'[Year]
            ,"DineIn_Sales_CY"
                ,SUM('Daily Reporting'[Total Dine In Sales])
            ,"DineIn_Sales_1PY"
                ,CALCULATE(
                SUM('Daily Reporting'[Total Dine In Sales])
                ,FILTER('Daily Reporting'
                        ,'Daily Reporting'[Weekday Nmbr]='Daily Reporting'[Weekday Nmbr]
                        &&'Daily Reporting'[Year]='Daily Reporting'[Year]-1))
            ,"DineIn_Sales_2PY"
                ,CALCULATE(
                SUM('Daily Reporting'[Total Dine In Sales])
                 ,ALL('Daily Reporting')
                        ,FILTER('Daily Reporting'
                        ,'Daily Reporting'[Week Number]='Daily Reporting'[Week Number]
                        &&('Daily Reporting'[Year])='Daily Reporting'[Year]-1))

    )

 

Here is the result in the table I'm seeing:

 

jordancole0517_0-1617908899215.png

 

 

1 REPLY 1
lbendlin
Super User
Super User

You will want to check out the "Year Over Year To Date"  pattern for that.  If you have a proper calendar table then you can use time intelligence functions  like SAMEPERIODLASTYEAR  combined with the appropriate "to date"  filters.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors