Forum

Creating a new date...
 
Notifications
Clear all

Creating a new date column not taking into account saturdays and sundays

3 Posts
2 Users
0 Reactions
61 Views
(@emr)
Posts: 4
Active Member
Topic starter
 

I have a table where I have a date column. I want a new column with dates based on the date column. Based on the criteria in column B (Type) date should still be the same if Type=1 and if Type=2 then I need the date to be reduced with 1 (the previous day). But I want only to count weekdays (mon-fri), so if the date in column A is a monday (07.03.2022) I want the new date to be friday (04.03.2022). Anyone know how to do this?

I have attached a small file with an example. 

 
Posted : 14/03/2022 6:00 am
(@mynda)
Posts: 4762
Member Admin
 

Hi Else Marie,

You can use a nested if formula:

= if [Type] = 1 then [Date] else if
Date.DayOfWeek([Date], Day.Monday)>5 then
Date.AddDays([Date],-2) else if
Date.DayOfWeek([Date], Day.Monday)>4 then
Date.AddDays([Date],-1) else if
Date.DayOfWeek([Date], Day.Monday)=0 then
Date.AddDays([Date],-3) else
Date.AddDays([Date],-1)

 

Mynda

 
Posted : 14/03/2022 8:22 pm
(@emr)
Posts: 4
Active Member
Topic starter
 

Thank you, I'll test this.

 

Else Marie

 
Posted : 16/03/2022 9:04 am
Share: