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

Week to date this week compared to week to date prior Week

Hi everyone, 

I need to calculate the number of units sold this week to date in one measure and with a 2nd measure compare it to the prior week to date, such that units from Sunday through Friday of this week are compared with units from Sunday through Friday of last week. I've worked out units week to date this week below, also worked out units prior *full* week (Sunday through Monday) however *week to date" prior week (as opposed to full week) evades me. Thanks in advance for any ideas:

 

Measures:

 

Units WTD =
VAR CurrentDate = LASTDATE ( 'Date'[CalendarDate] )
VAR DayNumberOfWeek = WEEKDAY ( LASTDATE ( 'Date'[CalendarDate] ), 3 )

 

RETURN
CALCULATE (SUM ( Orders[Units] ),
DATESBETWEEN ('Date'[CalendarDate],DATEADD ( CurrentDate, -1 * DayNumberOfWeek, DAY ),CurrentDate))


Units Prior Full Week =
VAR CurrentWeek = SELECTEDVALUE('Date'[WeekNo])
VAR CurrentYear = SELECTEDVALUE('Date'[Year])
VAR MaxWeekNumber = CALCULATE(MAX('Date'[WeekNo]), ALL('Date'))

RETURN
SUMX(FILTER(ALL('DATE'),IF(CurrentWeek = 1,'Date'[WeekNo] = MaxWeekNumber && 'Date'[Year] = CurrentYear - 1,
'Date'[WeekNo] = CurrentWeek - 1 && 'Date'[Year] = CurrentYear )),
[Units]) 

 

Seems like it should be something like this:

 

Units WTD Prior Week =
VAR CurrentDate = LASTDATE('Date'[CalendarDate])
VAR DayNumberOfWeek = WEEKDAY(LASTDATE('Date'[CalendarDate]),3)
VAR CurrentWeek = SELECTEDVALUE('Date'[WeekNo])
VAR CurrentYear = SELECTEDVALUE('Date'[Year])
VAR MaxWeekNumber = CALCULATE(MAX('Date'[WeekNo]), ALL('Date'))

RETURN
SUMX(
FILTER(ALL('Date'), AND(
IF(CurrentWeek = 1,
'Date'[WeekNo] = MaxWeekNumber && 'Date'[Year] = CurrentYear - 1,
'Date'[WeekNo] = CurrentWeek - 1 && 'Date'[Year] = CurrentYear ), DATESBETWEEN('Date'[CalendarDate],DATEADD(CurrentDate,-1*DayNumberOfWeek,DAY),CurrentDate))),
[Units])

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I came up with the following solution:

 

Revenue WTD =
VAR CurrentDate=LASTDATE('Date'[CalendarDate])
VAR DayNumberOfWeek=WEEKDAY(LASTDATE('Date'[CalendarDate]),3)
RETURN
CALCULATE(SUM(Orders[total_price]),DATESBETWEEN('Date'[CalendarDate],DATEADD(CurrentDate, DayNumberOfWeek * -1, DAY),CurrentDate))

 

Revenue WTD Prior Week =
VAR CurrentDate=LASTDATE('Date'[CalendarDate])
VAR PriorWeekDate=DATEADD(CurrentDate,-7,DAY)
VAR DayNumberOfWeek=WEEKDAY(LASTDATE('Date'[CalendarDate]),3)
RETURN
CALCULATE(SUM(Orders[total_price]),DATESBETWEEN('Date'[CalendarDate],DATEADD(PriorWeekDate, DayNumberOfWeek * -1, DAY), PriorWeekDate))

View solution in original post

2 REPLIES 2
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

Here are some references for you. If it is not your case, please share a simplified data sample and expected output.

https://community.powerbi.com/t5/Desktop/Last-Week-Previous-Week-Calculation-Formula-Review/td-p/218653

https://community.powerbi.com/t5/Desktop/Week-over-Week/td-p/379226

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

I came up with the following solution:

 

Revenue WTD =
VAR CurrentDate=LASTDATE('Date'[CalendarDate])
VAR DayNumberOfWeek=WEEKDAY(LASTDATE('Date'[CalendarDate]),3)
RETURN
CALCULATE(SUM(Orders[total_price]),DATESBETWEEN('Date'[CalendarDate],DATEADD(CurrentDate, DayNumberOfWeek * -1, DAY),CurrentDate))

 

Revenue WTD Prior Week =
VAR CurrentDate=LASTDATE('Date'[CalendarDate])
VAR PriorWeekDate=DATEADD(CurrentDate,-7,DAY)
VAR DayNumberOfWeek=WEEKDAY(LASTDATE('Date'[CalendarDate]),3)
RETURN
CALCULATE(SUM(Orders[total_price]),DATESBETWEEN('Date'[CalendarDate],DATEADD(PriorWeekDate, DayNumberOfWeek * -1, DAY), PriorWeekDate))

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors