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
zjwright
Frequent Visitor

Transform Date to Start of the Week giving the End of the Week date instead

Hello All,

 

I checked the community but did not see a post for this bug yet. I have noticed when I do a simple transformation on a date column, sometimes (not everytime) when I transform the date to be the start of the week, power query actually converts to the end of the week instead. Seems like a fairly simple bug, has anyone else noticed this? If so does anyone know if Microsoft is aware of the issue yet?

1 ACCEPTED SOLUTION

I doubt it is a bug at all.

 

The formula used by the transform tab assumes a default first day of the week. The transform tab does not allow you to change that. It sounds like your system is assuming a first day of the week that is different from what you expect.

 

You will need to edit the actual code.

 

In the formula bar, you probably see something  like:

 

= Table.TransformColumns(#"Changed Type",{{"date",Date.StartOfWeek, type date}})

 

although the #"Changed Type" variable will be the name of whatever the previous step to your transformation is named (in the Applied Steps window), and "date" will be the name of the date column you are transforming.

 

To specify a particular day of the week to be the first day, you can edit it to something like (if Monday is your first day):

 

= Table.TransformColumns(#"Changed Type",{{"date",each Date.StartOfWeek(_,Day.Monday), type date}})

 

View solution in original post

5 REPLIES 5
zjwright
Frequent Visitor

Hi All, 

 

Thanks for your responses. I am seeing this issue in the power query editor when using the transform tab & selecting "start of week" when transforming a date column

I doubt it is a bug at all.

 

The formula used by the transform tab assumes a default first day of the week. The transform tab does not allow you to change that. It sounds like your system is assuming a first day of the week that is different from what you expect.

 

You will need to edit the actual code.

 

In the formula bar, you probably see something  like:

 

= Table.TransformColumns(#"Changed Type",{{"date",Date.StartOfWeek, type date}})

 

although the #"Changed Type" variable will be the name of whatever the previous step to your transformation is named (in the Applied Steps window), and "date" will be the name of the date column you are transforming.

 

To specify a particular day of the week to be the first day, you can edit it to something like (if Monday is your first day):

 

= Table.TransformColumns(#"Changed Type",{{"date",each Date.StartOfWeek(_,Day.Monday), type date}})

 

v-stephen-msft
Community Support
Community Support

Hi @zjwright ,

 

I guess you're talking about the Date.StartOfWeek function, right?

If so, there's an optional parameter for you to set the start day number.

vstephenmsft_0-1727677032201.png

Please try setting a specific start day for your formula.
For example, find the start of the week for Tuesday, October 11th, 2011, using Monday as the start of the week.

Date.StartOfWeek(#datetime(2011, 10, 11, 8, 10, 32), Day.Monday)

 

Reference: Date.StartOfWeek - PowerQuery M | Microsoft Learn

 

Best Regards,

Stephen Tao

 

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

 

ronrsnfld
Super User
Super User

I cannot reproduce that.

Perhaps there is something incorrect about your coding.

Please provide examples of your data, along with your actual code (from the Advanced Editor) and your actual and expected results so we can help you troubleshoot this.

Omid_Motamedise
Memorable Member
Memorable Member

Can you give an example of a date and its transformed value, and what is your prefered starting day for a week

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.