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! Learn more

Reply
Anonymous
Not applicable

Same day last week calculation

Hi Folks,

 

I want to calculate Same day last week sales. I am using the below dax:

M.Sameday_LW Sales = CALCULATE(SUM(vTransaction[EX_GST_AMT]),
DATEADD('Dim Date'[CALENDAR_DATE_FMTD],-7,DAY))
Which is working fine is used in the below format(i.e. going date by date):

Location       Department        CALENDAR_DATE_FMTD    Current Date       M.Sameday_LW Sales
101       12         30/09/2019 0:00    10           1
101       12        1/10/2019 0:00    12           2
101       12        2/10/2019 0:00    13           3
101       12        3/10/2019 0:00       14          4
101       12        4/10/2019 0:00    15          5
101       12        5/10/2019 0:00    16          6 
101       12        6/10/2019 0:00    17          7
101       12        7/10/2019 0:00    18         10
101       12        8/10/2019 0:00    19         12
101       12        9/10/2019 0:00    20         13
101       12       10/10/2019 0:00    21         14
101      12      11/10/2019 0:00    22         15
101      12      12/10/2019 0:00    23         16
101      1213/10/2019 0:00    24         17
Total     244         125

But Fails when used in the below format(i.e. if we eliminate the date factor) its just shows the sum of the entire date selection instead of showing same day last week value which here should be $17:
 
Location      Department     Current Date        M.Sameday_LW Sales
101      12     24       125
Expected values:
 
Location      Department      Current Date    M.Sameday_LW Sales
101     12      24      17
 
Thanks in Advance!
1 REPLY 1
lbendlin
Super User
Super User

how do you "eliminate the date factor"  when you still show the 24 date value?  Do you have a filter elsewhere?

 

You may want to add variables to prevent the filter context transition from messing with your expected results.

 

M.Sameday_LW Sales =
var d=selectedvalue('Dim Date'[CALENDAR_DATE_FMTD])
Return CALCULATE(SUM(vTransaction[EX_GST_AMT]), DATEADD(d,-7,DAY))

 

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.