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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Same day last week

Hi Folks,


I am using the below dax for calculating Sales for Same day last week:

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 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous ,

Basically 7 days behind measure will keep on running past and give you data unless you filter a date . when you select

 a date in the calendar then it will stop

 

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

 

This set should work better

This Day = CALCULATE(sum(vTransaction[EX_GST_AMT]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
M.Sameday_LW Sales = CALCULATE(sum(vTransaction[EX_GST_AMT]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-7))

 

but this will also depend on a max date to take max date from the table if needed

 

This Day = CALCULATE(sum(vTransaction[EX_GST_AMT]), FILTER(ALL('Date'),'Date'[Date]=max('vTransaction'[Date])))
M.Sameday_LW Sales = CALCULATE(sum(vTransaction[EX_GST_AMT]), FILTER(ALL('Date'),'Date'[Date]=max('vTransaction'[Date])-7))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,

Basically 7 days behind measure will keep on running past and give you data unless you filter a date . when you select

 a date in the calendar then it will stop

 

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

 

This set should work better

This Day = CALCULATE(sum(vTransaction[EX_GST_AMT]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
M.Sameday_LW Sales = CALCULATE(sum(vTransaction[EX_GST_AMT]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-7))

 

but this will also depend on a max date to take max date from the table if needed

 

This Day = CALCULATE(sum(vTransaction[EX_GST_AMT]), FILTER(ALL('Date'),'Date'[Date]=max('vTransaction'[Date])))
M.Sameday_LW Sales = CALCULATE(sum(vTransaction[EX_GST_AMT]), FILTER(ALL('Date'),'Date'[Date]=max('vTransaction'[Date])-7))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

HI @Anonymous 

Probably, you are using the DAX mentioned by you as a measure.

Create a column using the same DAX and your issue will be resolved.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.