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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Previous week calculation

Hi everyone,

 

Iam calculating the total number of previous week to have change week over week with code below, but in the result it shows same number for every weeks.

PreviousWeekCount =
VAR CurrentWeekOffset = MAX('CALENDAR'[WeekNumber])
RETURN
CALCULATE(
    COUNT('E'[Order Number]),
    FILTER(
        ALL('Calendar'),
        'CALENDAR'[WeekNumber] = CurrentWeekOffset - 1
    )
)
 
Please help.
Thank you guys in advance
4 REPLIES 4
Anonymous
Not applicable

Hi guys, @Ahmedx @lbendlin 

 

I have table calendar here, I still can calculate change in Weeknumber  with code above (i guess because it is number), but i wanna display in Weekdisplay (text), so if i apply for Weekdisplay with same code, just change weeknumber = weekdisplay it did not work.

kell_0-1719540841347.png

 

Please help, thank you guys.

week numbers won't work reliably across year boundaries. Safest approach is to subtract 7 days or to divide the day number by 7.

Ahmedx
Super User
Super User

you need to add the following column to the calendar table and then create this measure
numweek = DATEDIFF(min('Calendar'[Date]),'Calendar'[Date],WEEK)

Screenshot_1.png
PreviousWeekCount =
VAR PreviosWeekOffset = MAX('CALENDAR'[numweek]) -1
RETURN
CALCULATE(
COUNT('E'[Order Number]),
FILTER(
ALL('Calendar'),
'CALENDAR'[numweek] = Previos
)
)

lbendlin
Super User
Super User

What is your definition of week?  How is this supposed to work across years?

 

Safest approach is to subtract 7 days.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors