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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Dynamic Calendar: Incorrect Week Number (53 and 1)

Hello -

 

I currently have a visual that compares the amount of Impressions from a Week over Week (WoW) basis.

 

Annotation 2021-01-14 104808.jpg

 

The formula works fine, however, I noticed that when it comes to the end of the year, and the start of the new year, the calculation malfunctions. And the reason is that the Week of Year has two different values for the WeekDate.

 

Example below:

 

On Sunday, December 27, 2020, the Week of Year contains 53 and 1.

 

Annotation 2021-01-14 112801.jpg

Is there anyway to fix this?

 

Here is the current PowerQuery formula I have for WeekOfYear:

= Table.AddColumn(#"Inserted Start of Week (WeekDate)", "Week of Year", each Date.WeekOfYear([Date]), Int64.Type)

 

Calculation used for Total Impressions Last Week:

 

TOTAL_IMPRESSIONS_LAST_WEEK = VAR CURRENTWEEK = SELECTEDVALUE('Calendar'[Week of Year])
VAR CURRENTYEAR = SELECTEDVALUE('Calendar'[Year])
VAR MAXWEEKNUMBER = CALCULATE(MAX('Calendar'[Week of Year]), ALL('Calendar'))

RETURN
SUMX(
      FILTER(ALL('Calendar'),
             IF(CURRENTWEEK = 1,
                  'Calendar'[Week of Year] = MAXWEEKNUMBER && 'Calendar'[Year] = CURRENTYEAR - 1,
                  'Calendar'[Week of Year] = CURRENTWEEK - 1 && 'Calendar'[Year] = CURRENTYEAR)),
       [TOTAL_IMPRESSIONS_THIS_WEEK])

 

3 REPLIES 3
AlB
Community Champion
Community Champion

@Anonymous 

Check this out as well

https://community.powerbi.com/t5/Desktop/how-to-adjust-week-number-in-date-dale/m-p/1598957#M647578

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

AlB
Community Champion
Community Champion

Hi @Anonymous 

See if this can help

https://community.powerbi.com/t5/Power-Query/Calender-table-with-Date-WeekOfYear-week-53/m-p/1597115

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Cheers 

 

SU18_powerbi_badge

Anonymous
Not applicable

Hi @AlB 

 

So, I added the ISO Week Number column to my Calendar table, and it seems to be doing the trick. But now, it doesn't work in my WoW visual.

 

The Previous Week Calculation I am using below is returning blank:

 

TOTAL_IMPRESSIONS_LAST_WEEK = VAR CURRENTWEEK = SELECTEDVALUE('Calendar'[ISOWeekNum])
VAR CURRENTYEAR = SELECTEDVALUE('Calendar'[Year])
VAR MAXWEEKNUMBER = CALCULATE(MAX('Calendar'[ISOWeekNum]), ALL('Calendar'))

RETURN
SUMX(
FILTER(ALL('Calendar'),
IF(CURRENTWEEK = 1,
'Calendar'[ISOWeekNum] = MAXWEEKNUMBER && 'Calendar'[Year] = CURRENTYEAR - 1,
'Calendar'[ISOWeekNum] = CURRENTWEEK - 1 && 'Calendar'[Year] = CURRENTYEAR)),
[TOTAL_IMPRESSIONS_THIS_WEEK])
 
Any idea what I'm missing?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Kudoed Authors