Forum Discussion

logan_logan's avatar
logan_logan
Icon for Helper I rankHelper I
2 years ago
Solved

Merge date with week number

Hi, I am trying to convert date into week suchway: Week number (fisrt day of that week - last day of that week) Example:     "Week-21 (20 May -26 May)" . I was able to extract week number "Week-21...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi logan_logan ,

    I create a table as you mentioned.

    Then I create a calculated column and here is the DAX code.

    Week Description =
    VAR WeekNumber =
        "Week-" & WEEKNUM ( [Date], 2 )
    VAR WeekStart =
        [Date] - WEEKDAY ( [Date], 2 ) + 1
    VAR WeekEnd = WeekStart + 6
    RETURN
        WeekNumber & " ("
            & FORMAT ( WeekStart, "dd MMM" ) & " - "
            & FORMAT ( WeekEnd, "dd MMM" ) & ")"
    

    Finally you will get what you want.

     

     

     

    Best Regards

    Yilong Zhou

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