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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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