Forum Discussion

asheyashey's avatar
asheyashey
Icon for Helper I rankHelper I
1 year ago
Solved

My X axis date column in weeks

The image is attached. I'm able to get it in Week "No" (month) format but not able to sort as in show in the above image. Each WeekNo should be from the start of the day which is Monday. Ple...
  • Shahid12523's avatar
    1 year ago

    Create a Week Start Date (Monday)


    WeekStartDate =
    'Date'[Date] - WEEKDAY('Date'[Date], 2) + 1


    -This ensures every date maps to the Monday of its week.
    -WEEKDAY(..., 2) makes Monday = 1, Sunday = 7

     

    2. Generate a Sortable Week Index Across Years


    WeekIndex =
    YEAR('Date'[WeekStartDate]) * 100 + WEEKNUM('Date'[WeekStartDate], 2)


    - This gives you values like 202401, 202402, etc.
    - Ensures proper chronological sorting across years.

     

    3. Create Display Format: WeekNo (Month)


    WeekLabel =
    "W" & WEEKNUM('Date'[WeekStartDate], 2) & " (" & FORMAT('Date'[WeekStartDate], "MMM") & ")"

     

    - Example: W32 (Aug)

     

    4. Sort the Display Column by WeekIndex


    In Power BI:
    - Go to the WeekLabel column.
    - Use "Sort by Column" → select WeekIndex.