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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
NDDD
Helper I
Helper I

13 weeks rolling with customer

Hi, 

 

 I created  measure that is suming 13 weeks prior current week and it is working fine when used "year week" column. Now when I try to add "customer name" from same table "year week" 13 weeks value is same for all customers, meainning it is not seprating the 13 weeks value by customer.

Any solution? 

 

Txn 

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

In general, if you cannot share your pbix, creating a sample report reproducing your issue will give more precise answers: How to Get Your Question Answered Quickly

Since you have not shared anything, I will assume your model only contains a single table, 'Orders'. I would at a separate date table, with relationship to order.

Then I would create this column in the date table:

WeekYearNum = 
var _startDate=DATE(2016,1,1)
var _currentDate=CALCULATE(SELECTEDVALUE(Dates[Date]))
var _distinctWeekNumbers = CALCULATETABLE(VALUES(Dates[Year-Week]),Dates[Date]<=_currentDate)
return
COUNTROWS(_distinctWeekNumbers)

 

This is a running week-year-number, so you can easily move back/forward any number of weeks, without having to think about changing years. 

With this column you can write your measure like this:

Sales last 13 weeks =
VAR _currentWeek =
    CALCULATE ( SELECTEDVALUE ( Dates[WeekYearNum] ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[SalesCol] ),
        FILTER (
            ALL ( Dates ),
            Dates[WeekYearNum] > _currentWeek - 13
                && Dates[WeekYearNum] <= _currentWeek
        )
    )


Then drag the Dates[Date] into the filter for your visual, choose relative date filtering, and choose show last 13 weeks:

sturlaws_0-1671717494736.png

 

 

View solution in original post

4 REPLIES 4
NDDD
Helper I
Helper I

Thank you @sturlaws  for fast replay, 

 

 I can't share the file sadly

 Bellow I managed to get 13 week order received and 13 week sales to get book to bill

NDDD_0-1671664449504.png

I used measure that is working fine when adding "year -week" as above 

13 WEEKS OR = VAR CURRENTWEEK = MAX(ORDERS[DATE.WEEKSUM])

RETURN

CALCULATE(SUM(ORDERS [VALUE]),FILTER(ALL(ORDERS), ORDERS [DATE.WEEKSUM]>CURRENTWEEK - 13 && ORDERS [DATE.WEEKSUM]<=CURRENTWEEK))

 

Now when I add Customer I get wrong result, point is to have "year-week" per customer to show 13 weeks or received

 

I hope I'm clear and thank you in advance 

sturlaws
Resident Rockstar
Resident Rockstar

In general, if you cannot share your pbix, creating a sample report reproducing your issue will give more precise answers: How to Get Your Question Answered Quickly

Since you have not shared anything, I will assume your model only contains a single table, 'Orders'. I would at a separate date table, with relationship to order.

Then I would create this column in the date table:

WeekYearNum = 
var _startDate=DATE(2016,1,1)
var _currentDate=CALCULATE(SELECTEDVALUE(Dates[Date]))
var _distinctWeekNumbers = CALCULATETABLE(VALUES(Dates[Year-Week]),Dates[Date]<=_currentDate)
return
COUNTROWS(_distinctWeekNumbers)

 

This is a running week-year-number, so you can easily move back/forward any number of weeks, without having to think about changing years. 

With this column you can write your measure like this:

Sales last 13 weeks =
VAR _currentWeek =
    CALCULATE ( SELECTEDVALUE ( Dates[WeekYearNum] ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[SalesCol] ),
        FILTER (
            ALL ( Dates ),
            Dates[WeekYearNum] > _currentWeek - 13
                && Dates[WeekYearNum] <= _currentWeek
        )
    )


Then drag the Dates[Date] into the filter for your visual, choose relative date filtering, and choose show last 13 weeks:

sturlaws_0-1671717494736.png

 

 

@sturlaws many thanks! 

sturlaws
Resident Rockstar
Resident Rockstar

@NDDD,

 

could you share your pbix-file? Or if it contains data you cannot share, create sample report reproducing your issue?

 

Cheers,
Sturla

 

How to Get Your Question Answered Quickly

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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