Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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.
Date | First Sunday of the Month |
1 Oct 2021 | 4 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.
Solved! Go to Solution.
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))
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.
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))
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
9 | |
8 | |
7 | |
7 |