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
Henrik_99
Resolver I
Resolver I

Slicer rolling week based on number of week

Hi

 

Is there a way to have a bar graph  shows the past 2, 4  or 8 rolling week  based on the slicer date value selected by the user.

 

Capture.JPG

Rgds Henrik

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Henrik_99 ,

You can refer the following links to get it:

Calculate Dynamic Rolling 4 Week Average based on multi-level category filters and using only week #

Rolling Dynamic Weeks =
VAR _selnumber =
    SELECTEDVALUE ( 'Numbers'[No movement in (weeks)] )
VAR _table =
    CALCULATETABLE (
        VALUES ( 'Table'[Week] ),
        FILTER (
            ALLSELECTED ( 'Table'[Week] ),
            'Table'[Week]
                >= MAX ( 'Table'[Week] ) - _selnumber - 1
                && 'Table'[Week] <= MAX ( 'Table'[Week] )
        )
    )
RETURN
    IF (
        COUNTAX ( _table, [Week] ) = _selnumber,
        SUMX ( _table, CALCULATE ( SUM ( 'Table'[value] ) ) )
    )

Calculate Relative Weeks in Power BI

 

If the above one can't help you get the desired result, please provide more sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Henrik_99 ,

You can refer the following links to get it:

Calculate Dynamic Rolling 4 Week Average based on multi-level category filters and using only week #

Rolling Dynamic Weeks =
VAR _selnumber =
    SELECTEDVALUE ( 'Numbers'[No movement in (weeks)] )
VAR _table =
    CALCULATETABLE (
        VALUES ( 'Table'[Week] ),
        FILTER (
            ALLSELECTED ( 'Table'[Week] ),
            'Table'[Week]
                >= MAX ( 'Table'[Week] ) - _selnumber - 1
                && 'Table'[Week] <= MAX ( 'Table'[Week] )
        )
    )
RETURN
    IF (
        COUNTAX ( _table, [Week] ) = _selnumber,
        SUMX ( _table, CALCULATE ( SUM ( 'Table'[value] ) ) )
    )

Calculate Relative Weeks in Power BI

 

If the above one can't help you get the desired result, please provide more sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

vicky_
Super User
Super User

Without being given more information, it's hard to say. I can suggest changing the slicer selection settings to "Single Value", and then use the SELECTEDVALUE(No movement in Weeks) to get your users' selected value. You can use that in your calculations for the bar graph values.

Vicky,

 

it`s simple table, see table with dimdate table:

 

Capture.JPG

 

thanks

 

Henrik

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.