Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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:
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.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.