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

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

Reply
ElliotP
Post Prodigy
Post Prodigy

Sum past week with dateadd function

Morning,

 

I could have sworn I have used this before and for some reason now it isn't working.

 

I'm attempting to calculate the sum of sessions of the past seven days on a rolling basis. I have a date table, with a relationship to the date of the table containing the number of sessions per day and date.

 

Formula used;

SumpastweekSessions = CALCULATE(Sum('NumberofSessions'[Sessions]), DATEADD('NumberofSessionsDateTable'[DateKey], -7,DAY))

The answer should be 30; but instead I'm recieving 2734.

 

When I change the number of the interval the value changes; I feel I'm missing something here.

 

 

1 ACCEPTED SOLUTION
ElliotP
Post Prodigy
Post Prodigy

I solved it lads, no clue what I'm feeling on this one. I'd love an explanation but I feel I just misinterpreted what DATEADD does a long time ago and I just haven't noticed I've been calculating the wrong values.

 

Code I ended up using;

SumpastweekSessions = CALCULATE(Sum('NumberofSessions'[Sessions]), DATESINPERIOD('NumberofSessionsDateTable'[DateKey],TODAY(),-7,DAy)) 

I tried datesbetween as well.

View solution in original post

1 REPLY 1
ElliotP
Post Prodigy
Post Prodigy

I solved it lads, no clue what I'm feeling on this one. I'd love an explanation but I feel I just misinterpreted what DATEADD does a long time ago and I just haven't noticed I've been calculating the wrong values.

 

Code I ended up using;

SumpastweekSessions = CALCULATE(Sum('NumberofSessions'[Sessions]), DATESINPERIOD('NumberofSessionsDateTable'[DateKey],TODAY(),-7,DAy)) 

I tried datesbetween as well.

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.