on 11-24-2022 8:45 AM
Dear Experts,
We've been using the daysbetween function in webi for a number of KPI reports on BI4.2.
Our business want us to change these KPI's to show working days between, including national holidays.
I believe this can be achieved using a custom function. Has anyone been able to produce such a solution?
Kind Regards
Simon
Hi,
I tried to play around little bit and If you want to built that in Webi (not in DB) the solution for "working days between" could be as following.
I have spit the calculation to 3 parts:
[Day of start] = DayNumberOfWeek([Start Date])
[Start week Days] = If [Day of start] = 1 Then 4
ElseIf [Day of start] = 2 Then 3
ElseIf [Day of start] = 3 Then 2
ElseIf [Day of start] = 4 Then 1
Else 0
[Whole Week Start] = RelativeDate( [Start Date];7 -DayNumberOfWeek([Start Date]))
[Whole Week End] = RelativeDate( [End Date]; -DayNumberOfWeek([End Date]))
[Whole Weekends] = DaysBetween([Whole Week Start];[Whole Week End]) /7
[Day of End] = DayNumberOfWeek([End Date])
[End week Days] = If [Day of End] <= 5 Then [Day of End]
Else 5
Final calculation would be:
[Working days between] = [Whole Weekends] * 5 + [Start week Days] + [End week Days]
I am not sure for which country you need to apply public holidays, however you can do it also hardcoded way if you know the exact days of the public holidays. Then you would need to compare whether they are fall on working days and whether they are between Start and End date.
However I strongly advise you to create solution on DB level with proper Calendar table as this will be more scalable and easier to maintain.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.