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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Berean_50
Helper I
Helper I

How to find out the first week day date of the month

Given a year (E.g. 2021) and month (E.g. October) how do you find out the date of the first Sunday of October, 2021?

I had a look look a the StartOfWeek function in M but it may take me to a previous month if the day of the week starts prior to the first day of the month.

 

DateFirst Sunday of the Month
1 Oct 20214 Oct 2021

 

So in my example, regardless whether the date is 1 Oct 2021 or 31 Oct 2021 it should return 4 Oct 2021 as the the date of the first Sunday in the month of October.

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

You can still use the M code StartOfWeek function; but start on the 7th of the month instead of the 1st:

 

 

   #"Added Custom" = Table.AddColumn(typed, "First Sunday of Month", each Date.StartOfWeek(
                Date.AddDays(
                    Date.StartOfMonth([Date]),6)), type date)

 

If you want the first Monday (or other day) of the month, you can use the optional argument for start of week:

 

#"Added Custom" = Table.AddColumn(typed, "First Sunday of Month", each Date.StartOfWeek(
                Date.AddDays(
                    Date.StartOfMonth([Date]),6), Day.Monday))

 

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

You can still use the M code StartOfWeek function; but start on the 7th of the month instead of the 1st:

 

   #"Added Custom" = Table.AddColumn(typed, "First Sunday of Month", each Date.StartOfWeek(
                Date.AddDays(
                    Date.StartOfMonth([Date]),6)), type date)

Why are you posting duplicates of my responses?  Not only in this thread, but in others also.

ronrsnfld
Super User
Super User

You can still use the M code StartOfWeek function; but start on the 7th of the month instead of the 1st:

 

 

   #"Added Custom" = Table.AddColumn(typed, "First Sunday of Month", each Date.StartOfWeek(
                Date.AddDays(
                    Date.StartOfMonth([Date]),6)), type date)

 

If you want the first Monday (or other day) of the month, you can use the optional argument for start of week:

 

#"Added Custom" = Table.AddColumn(typed, "First Sunday of Month", each Date.StartOfWeek(
                Date.AddDays(
                    Date.StartOfMonth([Date]),6), Day.Monday))

 

LuukTijssen2
Frequent Visitor

I'd made a caluclated culumn like this in dax:
First Sunday Of The Month =
var firstdayofmonth = STARTOFMONTH([Date])
var daystillnextsunday = 7 - WEEKDAY(firstdayofmonth,2)
return firstdayofmonth + daystillnextsunday

In PowerQuery you can do the same, but as you cannot config weekday like in dax you'd ened a lil adjustment:
AddFirstsundayofmonth =  Table.AddColumn(#"Previousstep", "First Sunday of Month", each Date.AddDays(Date.StartOfMonth([Date]), 6-Date.DayOfWeek(Date.StartOfMonth([Date])) ) , type datetime),

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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