Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
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
Solved! Go to Solution.
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:
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.
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
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 60 | |
| 59 | |
| 45 | |
| 17 | |
| 17 |
| User | Count |
|---|---|
| 115 | |
| 112 | |
| 38 | |
| 35 | |
| 26 |