Power Query Language M Start of Week

4 Comments

There is a function called StartOfWeek that displays the start of the week in Power Query formula language.

Syntax: Date.StartOfWeek(<date>)

The week starts on Sunday and runs through to Saturday. To use Monday to Friday, you can add a day to it using the function Date.AddDays(<date>, 1).

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

4 Responses to Power Query Language M Start of Week

  1. This only works when there are no weekend dates to convert. Sunday will be lumped in with the next week. Instead, use Date.StartOfWeek([Date of Service],Day.Monday)) to set Monday as the start of the week.

  2. That makes sense Carlo. You’re one of the first people I see using the shorthand value.

    I discovered the Day.Type (second argument of Date.DayOfWeek) is an enumeration. Meaning you can use either the long values (Day.Sunday) or the shorthand (0).

    For example:

    Argument Value
    Day.Sunday 0
    Day.Monday 1
    Day.Tuesday 2
    Day.Wednesday 3
    Day.Thursday 4
    Day.Friday 5
    Day.Saturday 6

    Pretty awesome! You can find which functions can make use of the Day.Type here: https://powerquery.how/day-type/

Leave a Reply

Your email address will not be published. Required fields are marked *