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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
vcm
New Member

How to calculate how many weeks are left in the year based on a non date type column?

I am trying to calculate how many weeks are left in the year based on a column that concatenates year + week. Example, the column I'm trying to base the calculation looks like:

 

Week Start 

202515

202552

202602

 

Ideally, I would like a measure that would tell me the following,

 

Week Start  Weeks Left in the Year

202515        38

202552        1

202602        50

 

I'm having some trouble figuring this out since I'm not using a date type column and I would like it to dynamically update since it will have multiple years included in the data set. Any ideas on how I can get it done?

 

Thanks

 

1 ACCEPTED SOLUTION
djurecicK2
Super User
Super User

Hi @vcm ,

 You could do something like this:

Weeks Left In Year = 52- RIGHT('Table'[Week Start],2)
 
djurecicK2_0-1768921539092.png

 

 

View solution in original post

5 REPLIES 5
FreemanZ
Community Champion
Community Champion

hi @vcm ,

 

try to write a measure like:

Weeks Left in Year = 
VAR TargetYear = LEFT(SELECTEDVALUE(data[Week Start]), 4)
VAR Jan1 = DATE(TargetYear,1,1)
VAR IsLeapYear =
    IF(
        (MOD(TargetYear, 4)=0
            && MOD(TargetYear,100)<>0)
        || MOD(TargetYear, 400)=0,
    TRUE, FALSE
    )
VAR Jan1Weekday = WEEKDAY(Jan1, 2)
VAR _Result =
    IF(
        Jan1Weekday=1 || (IsLeapYear && Jan1Weekday=7), 53, 52
    ) -
    RIGHT(MAX(data[Week Start]),2)
RETURN _Result

 

it worked like:

FreemanZ_0-1768922883982.png

 

djurecicK2
Super User
Super User

Hi @vcm ,

 You could do something like this:

Weeks Left In Year = 52- RIGHT('Table'[Week Start],2)
 
djurecicK2_0-1768921539092.png

 

 

This might be an issue if there are 53 weeks in a year, like 2015, 2020. 

Agreed, it just works for my purposes since some other work is done to remedy it.

rohit1991
Super User
Super User

Hii @vcm 

 

Since your column is in YYYYWW format (year + week) and not a true date, you can extract the year and week number and calculate remaining weeks using a standard 52-week year. The logic is simply 52 minus the current week number, adjusted per year.

Weeks Left in Year =
VAR YearValue =
    INT ( SELECTEDVALUE ( 'Table'[Week Start] ) / 100 )
VAR WeekValue =
    MOD ( SELECTEDVALUE ( 'Table'[Week Start] ), 100 )
RETURN
    52 - WeekValue + 1

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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