Forum Discussion

SurendraD's avatar
SurendraD
Frequent Visitor
2 years ago
Solved

Calculating Week number from today to back dated for last 5 Week

Hi All,  I have a column of dates like this  Date 3/22/2024 3/21/2024 3/20/2024 3/19/2024 3/18/2024 3/17/2024 3/16/2024 3/15/2024 3/14/2024 3/13/2024 3/12/2024...
  • lbendlin's avatar
    2 years ago

    Dates =
    ADDCOLUMNS (
        CALENDAR ( "2024-01-01", TODAY () ),
        "WeekBack",
            VAR wd =
                WEEKDAY ( TODAY (), 2 )
            VAR wb =
                INT ( DIVIDE ( 14 + TODAY () - wd - [Date], 7 ) )
            RETURN
                IF ( wb < 6, FORMAT ( wb, "\W#" ) )
    )
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi SurendraD 

     

    Your solution is great, lbendlin. It worked like a charm! Here I have another idea in mind, and I would like to share it for reference.

     

    You can try this calculated column as follows.

    Week Number = 
    VAR CurrentWeek = WEEKNUM(MAX([Date]), 2)
    VAR DateWeek = WEEKNUM([Date], 2)
    RETURN IF((CurrentWeek - DateWeek + 1) <= 5, "W" & CurrentWeek - DateWeek + 1, BLANK())

     

    Result:

     

    When I changed the date to today (3/25/2024):

     

    Best Regards,
    Yulia Xu

     

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