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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
c_cook28954
Advocate I
Advocate I

Power Query Start of Month - Not True Start of Month

I'm sure other users are already aware of this but, if not, it looks like the Start of Month function in Power Query is based on a four day period (starts on Monday, ends on Sunday).

 

This means that, unless a date starts exactly on a Monday, the Start of Month function will produce the previous months date for the first (7-{insert day of week]) which can be misleading when you're performing calculations - sample below: 

c_cook28954_1-1684984572918.png

 

If you're looking for the start of the specific month you're analyzing, it's more accurate to create a calculated column based on the DAX function STARTOFMONTH as this produces the first value of the month in question. 

1 ACCEPTED SOLUTION
collinsg
Super User
Super User

Good day c_cook28954,

From your screen shot I interpret the first column as the date which is the starting point for calculating the other columns. The second column looks like "Start of Week". The third column looks like it is the one you wish to be "Start of Month". However it looks to me as if this column is the start of the month for the start of week column. Could it just be a "typo" that has resulted in the your column (rather than your first) being the argument of your start of month function? I reproduced your first column and added columns for start of week, start of month and start of month of start of week. Everything behaved correctly as per the screen shot below.

collinsg_0-1684996118186.png

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),

#"Add Start of Week" = Table.AddColumn(
#"Changed Type",
"Start of Week",
each Date.StartOfWeek( [Date] ),
type date),
#"Add Start of Month" = Table.AddColumn(
#"Add Start of Week",
"Start of Month",
each Date.StartOfMonth( [Date] ),
type date),
#"Add Start of Month of Start of Week" = Table.AddColumn(
#"Add Start of Month",
"Start of Month of Start of Week",
each Date.StartOfMonth( [Start of Week] ),
type date)
in
#"Add Start of Month of Start of Week" 

 

View solution in original post

2 REPLIES 2
collinsg
Super User
Super User

Good day c_cook28954,

From your screen shot I interpret the first column as the date which is the starting point for calculating the other columns. The second column looks like "Start of Week". The third column looks like it is the one you wish to be "Start of Month". However it looks to me as if this column is the start of the month for the start of week column. Could it just be a "typo" that has resulted in the your column (rather than your first) being the argument of your start of month function? I reproduced your first column and added columns for start of week, start of month and start of month of start of week. Everything behaved correctly as per the screen shot below.

collinsg_0-1684996118186.png

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),

#"Add Start of Week" = Table.AddColumn(
#"Changed Type",
"Start of Week",
each Date.StartOfWeek( [Date] ),
type date),
#"Add Start of Month" = Table.AddColumn(
#"Add Start of Week",
"Start of Month",
each Date.StartOfMonth( [Date] ),
type date),
#"Add Start of Month of Start of Week" = Table.AddColumn(
#"Add Start of Month",
"Start of Month of Start of Week",
each Date.StartOfMonth( [Start of Week] ),
type date)
in
#"Add Start of Month of Start of Week" 

 

You're right - looked back at my advanced editor and I had chosen Start of Week by mistake when creating my start of month column. 

 

I'd still naturally expect that a start of Month function applied to a Start of Week date would produce a true Start of Month date and not one adjusted to look at the first Monday of the 30 day period and trace it back to a different month. 

 

Appreciate the help anyway - interesting to know for future reference

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors