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
coochy5
Helper II
Helper II

Dax assistance needed - shift/rotation calendar needed in conjunction with a vacation calender.

Hi all,

Already posted a q about this - in the general group, but I think it's died.

I've created a pbix with a matrix view that needs to show vacation days and shift days off.

Multiple shifts involved, various (historical) start dates.

This is what I'm trying to recreate - was built in C#, but is dying:

coochy5_0-1729541899702.png

 

Each worker has a ‘WorkScheduleCalender’ string on their HR record, which I’ve delineated out into a ‘Rotation’ and ‘Crew’ field in a sql view, for slicers.  (Not sure that is helping, or hindering me !)

I’ve got as far as creating a version, that operates well on just the vacation days off basis – I really have no idea how to incorporate the shift off days, into the same matrix visual.

 

This is as far as I have been able to go with just the vacation/day off calendar - not yet able to incorporate shift days off.

 

coochy5_1-1729541921771.png

Assumptions.  Shift rotations don't overlap.  Employees don't book vacations during shift off days.

 

Sample of the shift rotations...

Work Schedule CalendarWork Week Start DayBiweekly Calculation Start DateConfigurable Calculation Period
Day Rate - 10/4 Rotation 2Tuesday2/21/2017Month Starting on Day 1
Day Rate / Bulker / Hourly - 22/13 Rotation 1 (Purple)Wednesday5/2/2018Month Starting on Day 1
Day Rate / Bulker / Hourly - 22/13 Rotation 2 (Orange)Wednesday5/9/2018Month Starting on Day 1
Day Rate / Bulker / Hourly - 22/13 Rotation 3 (Grey)Wednesday5/16/2018Month Starting on Day 1
Day Rate / Bulker / Hourly - 22/13 Rotation 4 (Brown)Wednesday5/23/2018Month Starting on Day 1
Day Rate / Bulker / Hourly - 22/13 Rotation 5 (Teal)Wednesday5/30/2018Month Starting on Day 1
Day Rate / Bulker /Salary - 15/6 Rotation 2 (Red)Wednesday2/8/2017Month Starting on Day 1
Day Rate / Bulker/ Salary - 15/6 Rotation 1 (Blue)Wednesday2/22/2017Month Starting on Day 1
Day Rate / Bulker/ Salary - 15/6 Rotation 3 (Yellow)Wednesday2/15/2017Month Starting on Day 1
Day Rate / Salary  - 10/4 Rotation 1Tuesday2/14/2017Month Starting on Day 1
Salary - 10/4 Rotation 1Sunday Month Starting on Day 1
Salary - 10/4 Rotation 2Sunday Month Starting on Day 1
Salary - 15/13 Rotation 1 (Magenta)Wednesday4/1/2020Month Starting on Day 1
Salary - 15/13 Rotation 2 (Pink)Wednesday4/15/2020Month Starting on Day 1
Salary - 15/13 Rotation 3Wednesday4/1/2020Month Starting on Day 1
Salary - 15/13 Rotation 4Wednesday4/1/2020Month Starting on Day 1
Hourly - 8/6 Rotation 1 (10hr)Wednesday2/15/2017Month Starting on Day 1
Hourly - 8/6 Rotation 1 Tu-Mo (10hr)Tuesday2/14/2017Month Starting on Day 1
Hourly - 8/6 Rotation 2 (10hr)Wednesday2/22/2017Month Starting on Day 1
Hourly - 8/6 Rotation 2 Tu-Mo (10hr)Tuesday2/21/2017Month Starting on Day 1

 

Any assistance or recommendations for an alternate method of replicating this, is greatly appreciated !!!

 

Sample data

(uploading again)

https://1drv.ms/u/c/7e54286728b81af7/EfllLfwmbrtDrt1BDkcmSJcBWt8iP5dvXyvD-RNhTErYkg?e=lFdMbH 

 

8 REPLIES 8
Anonymous
Not applicable

Hi @coochy5

 

Please verify if the following is helpful.

 

Preparation of the table:

vyajiewanmsft_1-1729565983512.png

vyajiewanmsft_2-1729565999983.png

vyajiewanmsft_3-1729566014985.png

Calendar = 
ADDCOLUMNS(
    CALENDAR(DATE(2024,1,1), DATE(2024,12,31)),
    "Year", YEAR([Date]),
    "Month", MONTH([Date]),
    "Day", DAY([Date]),
    "Weekday", WEEKDAY([Date],2)
)

vyajiewanmsft_4-1729566027639.png


Measure:

ShiftStatus = 
VAR StartDate = MAX('Shift Schedule'[Shift Start Date])  
VAR CurrentDate = MAX('Calendar'[Date])  
VAR WorkDays = MAX('Shift Schedule'[Work Days])  
VAR OffDays = MAX('Shift Schedule'[Off Days])  
VAR TotalDays = WorkDays + OffDays  
VAR DaysPassed = DATEDIFF(StartDate, CurrentDate, DAY)  
VAR CyclePosition = MOD(DaysPassed, TotalDays)  
RETURN 
IF(CyclePosition < WorkDays, "workday" ,"offday")
VacationStatus = 
IF(
    MAX('Calendar'[Date]) >= MAX('Vacation'[Vacation Start Date]) && 
    MAX('Calendar'[Date]) <= MAX('Vacation'[Vacation End Date]),
    "Vacation", 
    BLANK()
)
FinalStatus = 
IF(
    NOT(ISBLANK(('Vacation'[VacationStatus]))),
    'Vacation'[VacationStatus],
    'Shift Schedule'[ShiftStatus]
)

Result for your reference:

vyajiewanmsft_5-1729566337132.png

Best regards,

Joyce

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

Many thanks for the response.  It is very helpful, and gets me much closer to what I'm trying to get - but not quite there.  I get it....don't get it !

I tried to use your suggestion - muddled up with my own - and confused myself and the result.

 

I've uploaded a newer version of the pbix - sample data.  I've added all of the shift schedules, and their start dates - I guess I'm mainly confused about the vacation piece - it's a one row per event data set - so not sure if I should set the vacation start and end to be the same.  

 

Sample set only includes workers on the same rotation, but different crews (colours) - and the crew colour would have a different/offset start day on/off.

 

https://drive.google.com/file/d/1OoPk-sxRww6XIrs2zbSaMUwz8BtZ8Wlz/view?usp=sharing 

 

Appreciate any further insight you could provide !

Thanks in advance !

Anonymous
Not applicable

Hi @coochy5 , 

 

I am currently unable to access your PBIX file.

 

Could you please try the following method instead?

 

Do not include sensitive information or anything not related to the issue or question.

 

vyajiewanmsft_0-1729762518989.png

 

Hi there.

Sorry to reach out directly, were you able to view my pbix ?  Seems to be shared ?

Anonymous
Not applicable

Hi @coochy5 ,

Please check the following measure:

IsShiftOffDayMeasure = 
VAR RotationDaysOn = VALUE(LEFT(SELECTEDVALUE('Fact Crew Worker Time Off V1 sample'[Rotation]), FIND("/", SELECTEDVALUE('Fact Crew Worker Time Off V1 sample'[Rotation])) - 1))
VAR RotationDaysOff = VALUE(RIGHT(SELECTEDVALUE('Fact Crew Worker Time Off V1 sample'[Rotation]), LEN(SELECTEDVALUE('Fact Crew Worker Time Off V1 sample'[Rotation])) - FIND("/", SELECTEDVALUE('Fact Crew Worker Time Off V1 sample'[Rotation]))))
VAR StartDate = 
    CALCULATE(
        MIN('Fact Crew Worker Time Off V1 sample'[Date]), 
        ALLEXCEPT('Fact Crew Worker Time Off V1 sample', 'Fact Crew Worker Time Off V1 sample'[Crew], 'Fact Crew Worker Time Off V1 sample'[Name])  
    )
VAR DaysSinceStart = DATEDIFF(StartDate, SELECTEDVALUE('Calendar'[Date]), DAY)
VAR CycleDays = RotationDaysOn + RotationDaysOff
RETURN
IF(
    MOD(DaysSinceStart, CycleDays) >= RotationDaysOn,
    1,  // offday
    0   // workday
)
Colour Format = 
IF([Value_per_day] = "V", "#fed70d",
IF([Value_per_day] = "U", "#fed68d",
IF([IsShiftOffDayMeasure] = 1, "#FFB6C1"
)))

Result for your reference:

vyajiewanmsft_0-1730686091015.png

Best regards,

Joyce

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Joyce,

Many thanks for your assistance again !

Almost there - I think somehow you had an older file - I had added a shift days off table in the sample data I see - I don't think it's in referenced in the measure - I see rotation mentioned, but it's crew colout that needs to be the driver of the shift days off calculation.

 

For example - in your example you sent back - both Edgar and Sean are on the same rotation (15/6) and on the same crew (colour) - yellow - so the shift days off would be the same for all of the yellow crew (who only have a 15/6 rotation).

 

coochy5_0-1730758522568.png

 

Any further thoughts ?  

The shift table - in my sample data is named 'Shift schedule'.  I could try and upload another copy, but that seems to not work correctly.  

This is it's format...if that helps ?

coochy5_1-1730758639128.png

I really appreciate your assistance with this !

 

Anonymous
Not applicable

Hi @coochy5 , 

 

Thank you for the file. I will need some time to work on it. I appreciate your patience

 

 

Hi,

Trying again.  Not quite sure why the sharing has been a challenge.

This is my sample pbix - all data has been changed - with a good selection of event dates (all event dates can be treated the same way - vacation/parental etc).  I've added a shift schedule table also.  From a vacation standpoint - this is working well, but I would like to try and overlay the shift schedule days off.

 

https://drive.google.com/file/d/1OoPk-sxRww6XIrs2zbSaMUwz8BtZ8Wlz/view?usp=sharing 

 

The result I am trying to achieve is this - where the yellow indicates the vacation, and the red is the shift schedule time off

 

coochy5_0-1729873165612.png

 

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.