Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
SophRow
Resolver II
Resolver II

Change week number to a date

Hi experts,

 

I currently have this date table and am plotting 'Week' on an x-axis.

 

SophRow_0-1724650021569.png

 

My end users want me to change 'Week X' to the first day of that week, for example, week 31 would be 28 July 2024.

 

Any tips here?

2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Hi @SophRow ,

 

Create a week number column then calculate the first day of each week number.

Week =
VAR FirstDay =
    CALCULATE ( MIN ( dates[date] ), ALLEXCEPT ( dates, dates[Week number] ) )
RETURN
    IF (
        FirstDay = dates[date],
        FORMAT ( dates[date], "dd/mm/yyyy" ),
        "Week " & dates[Week number]
    )

As the calculated column above will generate text strings, the values will be sorted alphabetically thus create a sort-by column.

Week Sort =
VAR FirstDay =
    CALCULATE ( MIN ( dates[date] ), ALLEXCEPT ( dates, dates[Week number] ) )
RETURN
    IF (
        FirstDay = dates[date],
        dates[Week number],
        dates[Week number] + 0.01
    )










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

shafiz_p
Resident Rockstar
Resident Rockstar

Hi @SophRow  Please find below image to calculate week start date.

shafiz_p_0-1724651488832.png

 

Hope this helps!!
If this solved your problem, please accept it as a solution!!

Best Regards,
Shahariar Hafiz

View solution in original post

3 REPLIES 3
Ray_Minds
Resolver IV
Resolver IV

Hi @SophRow 

1. Add a 'Start of Week' Column to Your Date Table:
First, you'll need to create a new column in your Date table that represents the start date of
each week.

Ray_Minds_0-1724655202479.png

 

This formula calculates the Monday of the week for each date, assuming your week starts on
Monday (which is common in many regions). If your week starts on a different day, you can
adjust the 2 in the WEEKDAY function accordingly (e.g., 1 for Sunday, 7 for Saturday).
2. Replace 'Week' with 'Start of Week' in Your Visual:
      Go to the visual where you're using 'Week' on the x-axis.
      Replace the 'Week' field with the new 'StartOfWeek' column.
3. Formatting the Date
To ensure the date is displayed in a user-friendly way, you might want to format the
'StartOfWeek' column as "dd MMM yyyy" (e.g., "28 July 2024").

Make sure to sort the x-axis by the 'StartOfWeek' column to ensure that the weeks are displayed
in the correct chronological order.
This approach will display the first day of the week instead of the week number, making it
clearer for your end users.

If your requirement is solved, please make THIS ANSWER a SOLUTION ✔️ and help other users find the solution quickly. Please hit the LIKE 👍 button if this comment helps you.

shafiz_p
Resident Rockstar
Resident Rockstar

Hi @SophRow  Please find below image to calculate week start date.

shafiz_p_0-1724651488832.png

 

Hope this helps!!
If this solved your problem, please accept it as a solution!!

Best Regards,
Shahariar Hafiz

danextian
Super User
Super User

Hi @SophRow ,

 

Create a week number column then calculate the first day of each week number.

Week =
VAR FirstDay =
    CALCULATE ( MIN ( dates[date] ), ALLEXCEPT ( dates, dates[Week number] ) )
RETURN
    IF (
        FirstDay = dates[date],
        FORMAT ( dates[date], "dd/mm/yyyy" ),
        "Week " & dates[Week number]
    )

As the calculated column above will generate text strings, the values will be sorted alphabetically thus create a sort-by column.

Week Sort =
VAR FirstDay =
    CALCULATE ( MIN ( dates[date] ), ALLEXCEPT ( dates, dates[Week number] ) )
RETURN
    IF (
        FirstDay = dates[date],
        dates[Week number],
        dates[Week number] + 0.01
    )










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.