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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
osinquinvdm
Advocate II
Advocate II

How to tweak IsInCurrentWeek to use Monday instead of Sunday as the first day of the week?

IsInCurrentWeek returns a logical value indicating whether the given Date occurred during the current week, as determined by the current date and time on the system.

 

Unfortunately the weeks start on Sunday when my weeks actually start on Monday.

 

What would be your suggestion as for tweaking this in order for IsInCurrentWeek to use Monday instead of Sunday as the first day of the week?

1 ACCEPTED SOLUTION

yep, that's what I ended up with

    #"real Week" = Table.SelectRows(Source, each Duration.Days(Duration.From(Today-[Date]))< Date.DayOfWeek(Today)),

thanks all for putting me on the right track!

 

View solution in original post

7 REPLIES 7
Phil_Seamark
Microsoft Employee
Microsoft Employee

You could add something like this to your DATE table

 

 

Weeks From Today = 
VAR Offset = WEEKDAY('Dates'[Date],2)
RETURN INT((Today() - ('Dates'[Date] - Offset) ) /7)

 

The current week will always carry a 0 (And this has been aligned to a Monday start.

 

This approach has the bonus that you can use the column in your filters and set Report/Page or Visual level filters to only show data for when this is between 0 and 13 if you want a rolling set of weeks.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

I think this is a good track but I want to do it in the back-end, in M not in DAX

Good Decision! 🙂

 

@MarcelBeug , @ImkeF or @Sean will have something for you in no time


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Subtract 1 day from your date: Date.IsInCurrentWeek(YourDate - #duration(1,0,0,0))

Specializing in Power Query Formula Language (M)
Sean
Community Champion
Community Champion
MarcelBeug
Community Champion
Community Champion

Actually, the first day of the week is culture dependent.

 

A better solution would be (in this example a column is added indicating if the date is in the current week):

 

= Table.AddColumn(PreviousStep, "InCurrentWeek", each [YourDate] >= Date.StartOfWeek(DateTime.Date(DateTime.LocalNow()), Day.Monday) and [YourDate] <= Date.EndOfWeek(DateTime.Date(DateTime.LocalNow()), Day.Monday))
Specializing in Power Query Formula Language (M)

yep, that's what I ended up with

    #"real Week" = Table.SelectRows(Source, each Duration.Days(Duration.From(Today-[Date]))< Date.DayOfWeek(Today)),

thanks all for putting me on the right track!

 

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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.