Forum Discussion

New_be's avatar
New_be
Icon for Helper V rankHelper V
2 years ago

Calendar: Create column that that shows 6 weeks from current week

Hi Expert,


General:

I failed to create a week column that plus 6 week from current week. Especially when it involves different year.

 

Question:
Now is Year 23 and week 52 for me. So, current YearWeek is 2352. If it didn't involve year changes, that would be easy as we only take the current YearWeek plus 6. But now YearWeek 2352. If just simply add 6, it will return 2358 which is wrong. It should return Year 24 week 06 (2406). Can you please guide? thank you in advance.

What I have in my calendar:

 

My desired visual. So that when I clicked column "Plus 6 week from current week" = true, it will show +6 weeks from current week only.

 

 

2 Replies

  • Dangar332's avatar
    Dangar332
    Icon for Resident Rockstar rankResident Rockstar

    HI, New_be 

    try below code for column
    just adjust column and table name

     

    Column = 
    var curr_year = YEAR(calender[Date])
    var nutoincrease = 6
    var yearweek = CONVERT((RIGHT(YEAR(calender[Date]),2)*100 +WEEKNUM(calender[Date]))+nutoincrease,INTEGER)
    var maxweek = WEEKNUM(DATE(curr_year,12,31))
    var next = CONVERT((RIGHT(YEAR(calender[Date]),2)+1)*100,INTEGER)  +nutoincrease
    return
    IF(WEEKNUM(calender[Date])=maxweek,next,yearweek)