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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
joshua1990
Post Prodigy
Post Prodigy

Show last 5 weeks based on selected week

Hi community!

I have a table that shows the sales pro each product per date. THen I have a calendar table linked to that table to aggegrate the data into weekly buckets.

Now I would like to show in a pivot table the last 5 weeks sales in thos format

Selected Week2024-012024-022024-032024-042024-052024-06
0156891 
02 68912
03  8912

 

It is like a waterfall, showing the last 5 weeks sales based on the selected week.

 

How would you build that?

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1708865865864.png

 

 

Jihwan_Kim_0-1708865845676.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

 

Expected result measure: = 
VAR _selectedyearweek =
    MAX ( 'Axis table'[weekenddate] )
VAR _t =
    WINDOW (
        1,
        ABS,
        5,
        ABS,
        FILTER (
            ALL ( 'Calendar'[Year-Week], 'Calendar'[weekenddate] ),
            'Calendar'[weekenddate] >= _selectedyearweek
        ),
        ORDERBY ( 'Calendar'[weekenddate], ASC )
    )
RETURN
    CALCULATE ( SUM ( Sales[Sales] ), KEEPFILTERS ( _t ) )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1708865865864.png

 

 

Jihwan_Kim_0-1708865845676.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

 

Expected result measure: = 
VAR _selectedyearweek =
    MAX ( 'Axis table'[weekenddate] )
VAR _t =
    WINDOW (
        1,
        ABS,
        5,
        ABS,
        FILTER (
            ALL ( 'Calendar'[Year-Week], 'Calendar'[weekenddate] ),
            'Calendar'[weekenddate] >= _selectedyearweek
        ),
        ORDERBY ( 'Calendar'[weekenddate], ASC )
    )
RETURN
    CALCULATE ( SUM ( Sales[Sales] ), KEEPFILTERS ( _t ) )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.