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

relative week filter

Hi, in my report I have bar chart with weeknr as x-axel ex 202223, I want have a weeknr range like from current week+20,

example: current week is 202244 so my x axel will be like 202244, 202245,202246...... 202311.

I dont have any date column only one weeknr column like 202021,202022 etc.

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Here is one way. 

Based on this sample data

sample table.jpg

I created a dimension table for weeks including an index column which we will use to filter the visual with a measure:

 

Week Table =
ADDCOLUMNS (
    VALUES ( 'Table'[Week] ),
    "Index", RANKX ( VALUES ( 'Table'[Week] ), 'Table'[Week],, ASC )
)

 

week dim.jpgmodel.jpg

 

 Create the following measure to add to the filters on the visual, settin the value to equals 1.

 

Filter weeks =
VAR _TodayWeek =
    YEAR ( TODAY () ) * 100
        + WEEKNUM ( TODAY () )
VAR _CurrWeekIndex =
    CALCULATE (
        MAX ( 'Week Table'[Index] ),
        FILTER ( ALL ( 'Week Table' ), 'Week Table'[Week] = _TodayWeek )
    )
RETURN
    COUNTROWS (
        FILTER (
            'Week Table',
            'Week Table'[Week] >= _TodayWeek
                && 'Week Table'[Index] <= _CurrWeekIndex + 20
        )
    )

 

result.jpg

 

 Sample PBIX file attached





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

1 REPLY 1
PaulDBrown
Community Champion
Community Champion

Here is one way. 

Based on this sample data

sample table.jpg

I created a dimension table for weeks including an index column which we will use to filter the visual with a measure:

 

Week Table =
ADDCOLUMNS (
    VALUES ( 'Table'[Week] ),
    "Index", RANKX ( VALUES ( 'Table'[Week] ), 'Table'[Week],, ASC )
)

 

week dim.jpgmodel.jpg

 

 Create the following measure to add to the filters on the visual, settin the value to equals 1.

 

Filter weeks =
VAR _TodayWeek =
    YEAR ( TODAY () ) * 100
        + WEEKNUM ( TODAY () )
VAR _CurrWeekIndex =
    CALCULATE (
        MAX ( 'Week Table'[Index] ),
        FILTER ( ALL ( 'Week Table' ), 'Week Table'[Week] = _TodayWeek )
    )
RETURN
    COUNTROWS (
        FILTER (
            'Week Table',
            'Week Table'[Week] >= _TodayWeek
                && 'Week Table'[Index] <= _CurrWeekIndex + 20
        )
    )

 

result.jpg

 

 Sample PBIX file attached





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.