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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
bilingual
Helper V
Helper V

Calender Week and Relative Date in Filter function - how to implement ISO Week?

I use the Relative Date filter in the filter function for showing the last 26 weeks. But the problem is start the Calender Week starts on Sunday, not on Monday... - anybody knows a workaround for this challenge?

4 REPLIES 4
amitchandak
Super User
Super User

@bilingual , A new column

ISO Week No = ([Date],21)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks Amit, but ISO Week or Weeks in generel does not work with the Relative Date filtering.

Anonymous
Not applicable

Hi @bilingual ,

 

I suggest you to create a date table with ISO weeknum by dax. Than you can create a measure to filter your visual to show data in last 26 weeks.

Date table:

Date =
ADDCOLUMNS (
    CALENDARAUTO (),
    "Year", YEAR ( [Date] ),
    "Month", MONTH ( [Date] ),
    "Weeknum", WEEKNUM ( [Date], 2 ),
    "YearMonth",
        YEAR ( [Date] ) * 100
            + MONTH ( [Date] )
)

Add calculated columns:

ISO 8601 WeekNum = 
VAR _COUNT0 =
    CALCULATE (
        COUNTROWS ( 'Date' ),
        FILTER (
            'Date',
            'Date'[Year] = EARLIER ( 'Date'[Year] )
                && 'Date'[WeekNum] - 1 = 0
        )
    )
VAR _BASENUM1 =
    IF ( _COUNT0 < 7, 'Date'[WeekNum] - 1, 'Date'[WeekNum] )
VAR _ISO_8601_WeekNum =
    IF (
        WEEKDAY ( DATE ( 'Date'[Year] - 1, 01, 01 ) ) <> 1
            && 'Date'[Year] = 'Date'[Year]
            && _BASENUM1 = 0,
        WEEKNUM ( DATE ( MIN ( 'Date'[Year] ), 12, 31 ), 1 ) - 1,
        _BASENUM1
    )
RETURN
    _ISO_8601_WeekNum
ISO_Year = 
VAR _COUNT0 =
    CALCULATE (
        COUNTROWS ( 'Date' ),
        FILTER (
            'Date',
            'Date'[Year] = EARLIER ( 'Date'[Year] )
                && 'Date'[WeekNum] - 1 = 0
        )
    )
VAR _BASENUM1 =
    IF ( _COUNT0 < 7, 'Date'[WeekNum] - 1, 'Date'[WeekNum] )
RETURN
IF(_BASENUM1 = 0,'Date'[Year] -1,'Date'[Year])
ISO YearWeekNum = 'Date'[ISO_Year]*100+'Date'[ISO 8601 WeekNum]
Rank = RANKX('Date','Date'[ISO YearWeekNum],,ASC,Dense)

Create a measure , add this measure into visual level filter and set it to show items when value =1.

Measure = 
VAR _TODAYRANK = CALCULATE(MAX('Date'[Rank]),FILTER(ALL('Date'),'Date'[Date] = TODAY()))

RETURN
IF(MAX('Date'[Rank])<=_TODAYRANK&&MAX('Date'[Rank])>=_TODAYRANK-26,1,0)

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Rico , thanks alot, however the

Measure = 
VAR _TODAYRANK = CALCULATE(MAX('Date'[Rank]),FILTER(ALL('Date'),'Date'[Date] = TODAY()))

RETURN
IF(MAX('Date'[Rank])<=_TODAYRANK&&MAX('Date'[Rank])>=_TODAYRANK-26,1,0)

I can not make it work as filter on matrix tables, do you know why?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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