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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Mateja
Helper II
Helper II

Counting weekend days as sick days if Friday and Monday were sick days

Hi,

 

I have a small challenge where I need to figure out how to count Saturday and Sunday as a Sick days if person was sick Friday and Monday.

I have a measure:

IsFullTimeSick =
VAR IllnessDate = 'F_illness'[Date]
VAR IllnessWeekDay = WEEKDAY(IllnessDate)   -- Get the day of the week (Sunday = 1, Monday = 2, ..., Saturday = 7)
VAR IsWeekend = IllnessWeekDay = 1 || IllnessWeekDay = 7   -- Check if the 'IllnessDate' is a Saturday or Sunday
VAR NormalWorkingHours =
    IF(
        NOT IsWeekend,
        MAXX(
            FILTER(D_WorkSchedule, D_WorkSchedule[Day] = UPPER(FORMAT(IllnessDate, "dddd"))),
            D_WorkSchedule[Hours]
        ),
        0   -- weekend hours are not present, normal working hours are 0 (no need to consider it as full-time sick)
    )
VAR IsFullTime = 'F_illness'[IllnessHours] >= NormalWorkingHours
RETURN
    IF(
        NOT IsWeekend,
        IF(
            IsFullTime,
            1, -- Flag for full-time sick leave (1).
            0  -- Flag for non-sick (0).
        ),
        0   -- For weekends, set the value to 0
    )

This measure crosschecks the illness hours against the regular working schedule (MON to FRI) and checks if a person was sick the whole working day. If yes, then 1

NOw based on the results from this Calculated column I need a measure that will count weekends as sick days if Friday and  Monday were sick days.
Visible from the picture 10 and 11/ 06 should be counted each as 1/sick day because  Fri and Mon are sick days 
Mateja_0-1690290583086.png

So I need a measure that will calculate weekends as sick days if the days around the weekend are sick days.

I also need help with the public holidays.
I have a table with public holidays with two columns Name and date.
I need to count public holidays as sick day if a person was sick the day before and the day after.

Thank you!

3 REPLIES 3
Anonymous
Not applicable

Hi @Mateja ,

If I understand correctly, it seems that you want to get the count of sick days. And it include the following conditions:

  • If the weekend is before or after sick days, then that weekend should include in sick days
  • If the public holiday is before or after sick days, then that public holiday should include in sick days

Could you please provide some raw data in the table 'F_illness', 'D_WorkSchedule' and 'public holiday' table

(exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Hi v-yiruan-msft,

 

F_illness data: can be found in reply under this one.


Public holiday table in form of querry:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdhNb9NgDAfwrxL1vEnPS563I7DBaQgJJITGDhGLWCWWSE0L7NuT2sNbEtuJ1NvfSdv8asfp7e3OGWcujR1fu4vdx/ZP9a1tDt9Pxrg0VFfN0+7u4n9RfWnKWHTTnLr7p+rLw+kw3M8KrBkLPvT9ffX+sB/Dapq6Mb1uhmN7qD6PJ5kf7F/im76bHR7wI9rhWN1MDhyDfH7XtmsPza/q06F5Gk9wNatx54PfDD/abtj33SL25/jrw/44zD9XxPc9Z4/9Mgtj9q7vhuP+eDouzmzdpavPFQ+H/XB8bIbq+nc7jcMkXhwdx/ht/3ff/Xyd2S1kFsisTIYFTiDDtJbIMA4iGeTeLMksWcpkUAO/B5YMYudZMsxqlsyuklmdzOpkViFzW8gc9EEtk2FBEMgwTRIZxlkkc1KXOeKQyaAGvjtL5ujSL8kwiyyZWyVzOpnTyZxC5reQeeiDKJNhQRLIPM1VlszTVOXJvESGQVDJoAZ+DywZxC6zZJgVlsyvknmdzOtkXiGrt5CNRR6/mECGBUUggxRuGCxZTWOXJ4McPv6MrN4wGLGmSGQQ28KSQeYMS1avktU6Wa2T1QpZ2EIWaLIJZIFmG0cGqTMSGcYyWZC6DAIbVbJArcKSBbj0fJdhxndZWCULOlnQyYJCFreQRdouBDIs8AJZnO8XU7JIY5cnixIZBHCLlcki7RAsGcb8vSxO7nNTsvgCIpBFxuQVWSQTliwRy5IswUgLOhkWKfeyRJOTI0s0NlmyBF0mL/lJIsNA77JEnciSYZxYsqSQpVWypJMlnSwrZJkeihSyvLYxYkEUyLK+MWYi4ckgh8e6GVmmFpHJMlx3scuysjFmhSyvkmWdLOtkRSEr1AEKGRTBk5FAVmiD4MgKzVWWDGKXRLIidRkE+AAvkhXaIViyQk/aS7KikJVVsqKTFZXMG5nMG1ocZLLnIvnfDyxwAtlzKpF5o3cZ5tCkUzIMvErmDe0QHBnG1nBk3shk3qyRee7vjRcybySyu38=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Column1", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "Holiday"}})
in
#"Renamed Columns"

WorkSchedule querry: 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8s3PS0msVNJRMtczVYrViVYKKU0tRhUJT03JQxcLySgtQhNyK8qECijFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Day = _t, Hours = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Day", type text}, {"Hours", type number}})
in
#"Changed Type"


I just need help to figure out how to count the weekends (count both saturday and sunday individually, so for every relevant weekend the count  shoul be 2) in which the employee was sick Friday before and Monday after that weekend. For public holidays I need a measure that will count holiday in which employee was sick day before AND after  the holiday. And then I need a measure that will add those counts to the count of the column IsFullTimeSick.


Thank you for the help 

 

DateEmp Hours
2022-04-01250
2022-04-04250
2022-04-05250
2022-04-06250
2022-04-07250
2022-04-08250
2022-04-11250
2022-04-12250
2022-04-13250
2022-04-19250
2022-04-20250
2022-04-21250
2022-04-22250
2022-04-23250
2022-04-24250
2022-04-25250
2022-04-26250
2022-04-27250
2022-04-28250
2022-04-29250
2022-04-30250
2022-05-01250
2022-05-02250
2022-05-03250
2022-05-04250
2022-05-06250
2022-05-09250
2022-05-10250
2022-05-23250
2022-05-24250
2022-05-25250
2022-05-26250
2022-05-27250
2022-05-28250
2022-05-29250
2022-05-30250
2022-05-31250
2022-06-01250
2022-06-02250
2022-06-03250
2022-06-04250
2022-06-05250
2022-06-06250
2022-06-07250
2022-06-08250
2022-06-09250
2022-06-10250
2022-06-11250
2022-06-12250
2022-06-13250
2022-06-14250
2022-07-06250
2022-07-07250
2022-07-08250
2022-07-11250
2022-07-12250
2022-07-13250
2022-07-14250
2022-07-15250
2022-07-16250
2022-07-17250
2022-07-18250
2022-07-19250
2022-07-20250
2022-07-21250
2022-07-22257
2022-07-25257.5
2022-07-26257.5
2022-07-27257.5
2022-07-28257.5
2022-07-29257
2022-08-08257.5
2022-08-09257.5
2022-08-10257.5
2022-08-11257.5
2022-08-12257
2022-08-15257.5
2022-08-16257.5
2022-08-17257.5
2022-08-18257.5
2022-08-19257
2022-08-22257.5
2022-08-23257.5
2022-08-24257.5
2022-08-25257.5
2022-08-26257
2022-08-29257.5
2022-08-30257.5
2022-08-31257.5
2022-09-01257.5
2022-09-02257
2022-09-05257.5
2022-09-06257.5
2022-09-07257.5
2022-09-08257.5
2022-09-09257
2022-09-12257.5
2022-09-13257.5
2022-09-14257.5
2022-09-15257.5
2022-09-16257
2022-09-19257.5
2022-09-20257.5
2022-09-21257.5
2022-09-22257.5
2022-09-23257
2022-09-26257.5
2022-09-27257.5
2022-09-28257.5
2022-09-29257.5
2022-09-30257
2022-10-03257.5
2022-10-04257.5
2022-10-05257.5
2022-10-06257.5
2022-10-07257
2022-10-10257.5
2022-10-11257.5
2022-10-12257.5
2022-10-13257.5
2022-10-14257
2022-10-17257.5
2022-10-18257.5
2022-10-19257.5
2022-10-20257.5
2022-10-21257
2022-10-24257.5
2022-10-25257.5
2022-10-26257.5
2022-10-27257.5
2022-10-28257
2022-10-31257.5
2022-11-01257.5
2022-11-02257.5
2022-11-03257.5
2022-11-04257
2022-11-07257.5
2022-11-08257.5
2022-11-09257.5
2022-11-10257.5
2022-11-11257
2022-11-14257.5
2022-11-15257.5
2022-11-16257.5
2022-11-17257.5
2022-11-18257
2022-11-21257.5
2022-11-22257.5
2022-11-23257.5
2022-11-24257.5
2022-11-25257
2022-11-28257.5
2022-11-29257.5
2022-11-30257.5
2022-12-01255
2022-12-02257
2022-12-05257.5
2022-12-06255
2022-12-07257.5
2022-12-08255
2022-12-09257
2022-12-12257.5
2022-12-13254.5
2022-12-14257.5
2022-12-15254.5
2022-12-16254
2022-12-19257.5
2022-12-20254
2022-12-21257.5
2022-12-22254
2022-12-23257
2022-12-27254
2022-12-28257.5
2022-12-29254
2022-12-30257
2023-01-02257.5
2023-01-03255
2023-01-04257.5
2023-01-05255
2023-01-06254.5
2023-01-09257.5
2023-01-10255
2023-01-11257.5
2023-01-12255
2023-01-13254.5
2023-01-16257.5
2023-01-17255
2023-01-18257.5
2023-01-19255
2023-01-20254.5
2023-01-23257.5
2023-01-24255
2023-01-25257.5
2023-01-26255
2023-01-27254.5
2023-01-30257.5
2023-01-31254.5
2023-02-01257.5
2023-02-02254.5
2023-02-03254
2023-02-06253.5
2023-02-07253.5
2023-02-08257.5
2023-02-09253.5
2023-02-10253
2023-02-13253.5
2023-02-14253.5
2023-02-15257.5
2023-02-16253.5
2023-02-17253
2023-02-20253.5
2023-02-21253.5
2023-02-22257.5
2023-02-23253.5
2023-02-24253
2023-02-27255.5
2023-02-28253.5
2023-03-01257.5
2023-03-02253.5
2023-03-03253
2023-03-06253.5
2023-03-07253.5
2023-03-08257.5
2023-03-09253.5
2023-03-10253
2023-03-13253.5
2023-03-14253.5
2023-03-15257.5
2023-03-16253.5
2023-03-17253
2023-03-20253.5
2023-03-21253.5
2023-03-22257.5
2023-03-23253.5
2023-03-24252.5
2023-03-27253.5
2023-03-28253
2023-03-29257.5
2023-03-30253
2023-03-31253
2023-04-03253.5
2023-04-04253.5
2023-04-05257.5
2023-04-11253.5
2023-04-12257.5
2023-04-13253.5
2023-04-14253
2023-04-17253
2023-04-18252.5
2023-04-19253
2023-04-20253.5
2023-04-21257
2023-04-24253.5
2023-04-25253.5
2023-04-26257.5
2023-04-27253.5
2023-04-28253
2023-05-01253.5
2023-05-02252.5
2023-05-03257.5
2023-05-04252.5
2023-05-08253.5
2023-05-09252.5
2023-05-10257.5
2023-05-11252.5
2023-05-12253
2023-05-15252.5
2023-05-16252.5
2023-05-17252.5
2023-05-19257
2023-05-22252.5
2023-05-23252.5
2023-05-24257.5
2023-05-25253.5
2023-05-26253
2023-05-30252.5
2023-05-31257.5
2023-06-01252.5
2023-06-02252
2023-06-06252.5
2023-06-07257.5
2023-06-08252.5
2023-06-09253
2023-06-12253.5
2023-06-13252.5
2023-06-14257.5
2023-06-15252.5
2023-06-16253
2023-06-27252.5
2023-06-28257.5
2023-06-29252.5
2023-06-30252
2023-07-03253
2023-07-04253
2023-07-05257.5
2023-07-06252.5
2023-07-07253
2023-07-10253
2023-07-11253
2023-07-12257.5
2023-07-13252.5
2023-07-14253
2023-07-17253
2023-07-18253
2023-07-19257.5
2023-07-20253
2023-07-21252.5

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (4,208)