Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I want to calculate the different between 2 column's date but it should not calculate the holidays or weekend.
for different between 2 days I had used
floor([Resolution Date]) - Floor([Date Created])
but I don't know how to extract holidays.
I would be so thankful if anyone help me 🙂
Hello, what you should do is create a table with your holidays and holidays, then create a flag so you can filter in the expressions, something like that.
//Create inline table of examples with holidays
HolidayDates:
Mapping
LOAD * inline [
HolidayDate,Flag
2023-01-01,1
2023-04-14,1
2023-07-04,1
2023-03-25,1
];
//Create master calendar table
LET vDateMin = Num(MakeDate(2023, 1, 1));
LET vDateMax = Num(Today());
[Temporary Calendar]:
LOAD $(vDateMin) + RowNo() - 1 as [Num Date],
Date($(vDateMin) + RowNo() - 1) as Date
AUTOGENERATE 1
WHILE $(vDateMin) + IterNo() - 1 <= $(vDateMax);
[Master Calendar]:
LOAD Date,
Year(Date) AS Year,
'S' & Ceil(Month(Date)/6) as Semester,
'Q' & Ceil(Month(Date)/3) as Trimester,
Month(Date) AS Month,
WeekDay(Date) AS Week,
Day(Date) AS Day,
WeekDay(Date) & '-' & Day(Date) AS PerWeek,
Num(Month(Date), '00') AS [Num Month],
Month(Date) & '-' & Right(Year(Date), 2) AS [Year Month],
Year(Date) & Num(Month(Date), '00') AS [NumYearMonth],
ApplyMap('HolidayDates',Date,0) AS Flag
RESIDENT [Temporary Calendar]
Order By Date Asc;
DROP TABLE [Temporary Calendar];
As you will see, a flag was created that has value 1 and 0, you use that in the expressions.
Example:
Sum({<Flag={'0'}>} Sales)
You can also review this code where the business days are obtained but the holidays are not considered since it is independent by country.
Greetings.
Use the NetWorkDays() functions
Hello, what you should do is create a table with your holidays and holidays, then create a flag so you can filter in the expressions, something like that.
//Create inline table of examples with holidays
HolidayDates:
Mapping
LOAD * inline [
HolidayDate,Flag
2023-01-01,1
2023-04-14,1
2023-07-04,1
2023-03-25,1
];
//Create master calendar table
LET vDateMin = Num(MakeDate(2023, 1, 1));
LET vDateMax = Num(Today());
[Temporary Calendar]:
LOAD $(vDateMin) + RowNo() - 1 as [Num Date],
Date($(vDateMin) + RowNo() - 1) as Date
AUTOGENERATE 1
WHILE $(vDateMin) + IterNo() - 1 <= $(vDateMax);
[Master Calendar]:
LOAD Date,
Year(Date) AS Year,
'S' & Ceil(Month(Date)/6) as Semester,
'Q' & Ceil(Month(Date)/3) as Trimester,
Month(Date) AS Month,
WeekDay(Date) AS Week,
Day(Date) AS Day,
WeekDay(Date) & '-' & Day(Date) AS PerWeek,
Num(Month(Date), '00') AS [Num Month],
Month(Date) & '-' & Right(Year(Date), 2) AS [Year Month],
Year(Date) & Num(Month(Date), '00') AS [NumYearMonth],
ApplyMap('HolidayDates',Date,0) AS Flag
RESIDENT [Temporary Calendar]
Order By Date Asc;
DROP TABLE [Temporary Calendar];
As you will see, a flag was created that has value 1 and 0, you use that in the expressions.
Example:
Sum({<Flag={'0'}>} Sales)
You can also review this code where the business days are obtained but the holidays are not considered since it is independent by country.
Greetings.
Use the NetWorkDays() functions