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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
JamieH
Helper I
Helper I

Date Table - Week Running From Wednesday to Tuesday

I have a daily date table and I would like one of the columns in there to be the date of the previous tuesday. By this, I mean that I would a column that contains the same date for a Wed, Thur, Fri, Sat, Sun, Mon & Tue before then updating 7 days in advance to the date of the Wednesday. Essentially having a week running from Wednesday to Tuesday.
To give you an example:

 

Date

Weekday

Week Starting Wednesday

22-Dec-2020

Monday

16-Dec-2020

22-Dec-2020

Tuesday

16-Dec-2020

23-Dec-2020

Wednesday

23-Dec-2020

24-Dec-2020

Thursday

23-Dec-2020

25-Dec-2020

Friday

23-Dec-2020

26-Dec-2020

Saturday

23-Dec-2020

27-Dec-2020

Sunday

23-Dec-2020

28-Dec-2020

Monday

23-Dec-2020

29-Dec-2020

Tuesday

23-Dec-2020

30-Dec-2020

Wednesday

30-Dec-2020

31-Dec-2020

Thursday

30-Dec-2020

1-Jan-2021

Friday

30-Dec-2020

 

I have found a couple of different methods on line but neither work 100% with them either being a day out through the year, or the calculation being made using the previous year end, which means it stops working when it hits a new year.  

Any suggestions on how to do this?

 

Here is my full code to create the table:

 

Date =
VAR MinYear = YEAR ( MIN ( 'Real_Time_ Data'[Createddate] ) )
VAR MaxYear = YEAR ( MAX ( 'Real_Time_ Data'[Createddate] ) )
RETURN
ADDCOLUMNS (
FILTER (
CALENDARAUTO( ),
AND ( YEAR ( [Date] ) >= MinYear, YEAR ( [Date] ) <= MaxYear )
),
"Weekday", FORMAT ( [Date], "dddd" ),
"Week Start Mon", format([Date] - weekday([Date],2) + 1,"dd-mmm-yyyy"),
"Week Num Monday", Year([Date]) & Weeknum( [Date], 2 ),
"Month Name", FORMAT ( [Date], "mmmm" ),
"Monthly", FORMAT([Date],"MMM") & " " & YEAR([Date]),
"Calendar Year", format ( [Date] , "yyyy" ),
"Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1 & " " & YEAR ( [Date] )
)

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@JamieH , I have given links for all 7 days calendars on this blog.

Any Weekday Week - Start From Any day of Week
https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Powe...

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
JamieH
Helper I
Helper I

This is great.  Thank you so much!

amitchandak
Super User
Super User

@JamieH , I have given links for all 7 days calendars on this blog.

Any Weekday Week - Start From Any day of Week
https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Powe...

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.