Forum Discussion

coochy5's avatar
coochy5
Icon for Helper II rankHelper II
1 year ago
Solved

Need to create a shift (days off) calendar in matrix visualisation - overlaid with vacations

Hi there,

Hoping for some assistance, as I've come completely unstuck with this, and not even sure if best handled within Power Query, or in DAX.

Why I don't know which it should be - trying to map the result on a calendar (matrix visualisation), in addition to actual crew vacation days.

 

I need to create a calendar, showing shift off days.  Many shifts, many with the same rotation - are differentiated by crew (colours), and each crew colour, even if on the same rotation, would have a different start date, to not overlap.

(on the visualisation - need a multi-select of the crew colours also)

 

Have tried this...

 

ShiftPattern = DATATABLE(
    "Crew", STRING,
    "DaysOn", INTEGER,
    "DaysOff", INTEGER,
    {
        {"Red", 15, 6},
        {"Yellow", 15, 6},
        {"Blue", 15, 6},
        {"Teal", 22, 13},
        {"Orange", 22, 13},
        {"Purple", 22, 13},
        {"Brown", 22, 13},
        {"Grey", 22, 13},
        {"Magenta", 15, 13},
        {"Pink", 15, 13}
        }
 
Here's the data I'm looking at
IdNameDaysOnDaysOffEffectiveDateIsActiveWorkdayName
1Red15610/23/20241Day Rate / Bulker - 15/6 Rotation 2 (Red)
2Yellow1562/15/20171Day Rate / Bulker - 15/6 Rotation 3 (Yellow)
3Blue1562/22/20171Day Rate / Bulker - 15/6 Rotation 1 (Blue)
4Teal22135/30/20181Day Rate / Bulker / Hourly - 22/13 Rotation 5 (Teal)
5Orange22135/9/20181Day Rate / Bulker / Hourly - 22/13 Rotation 2 (Orange)
6Purple22135/2/20181Day Rate / Bulker / Hourly - 22/13 Rotation 1 (Purple)
7Brown22135/23/20181Day Rate / Bulker / Hourly - 22/13 Rotation 4 (Brown)
8Grey22135/16/20181Day Rate / Bulker / Hourly - 22/13 Rotation 3 (Grey)
9Magenta15134/1/20201Salary - 15/13 Rotation 1 (Magenta)
10Pink15134/15/20201Salary - 15/13 Rotation 2 (Pink)
 
 
This result, is close....but the shift days off are not correct/mapping correctly.
(As you'll see....Yellow crew - should all be off shift on the same dates, all Red crew off at the same time (as all other Red crew), but Red would not be off at the same time as Yellow.
(measure for this pbix is 
Colour Format =
IF([Value_per_day] = "V", "#fed70d",
IF([Value_per_day] = "U", "#fed68d",
IF([IsShiftOffDayMeasure] = 1, "#FFB6C1"
)))
 
 

Still unable to upload pbix....

 
Hoping someone can help ???
  • If you change the isOff measure to...

    isOff = 
    var _employee = 
    SELECTEDVALUE(vacationTable[Name])
    var _shiftEffectDate = 
    MINX(shift_table, shift_table[EffectiveDate])
    var _modValue = 
    MINX(shift_table, shift_table[DaysOn]) + MINX(shift_table, shift_table[DaysOff])
    var _comparisonValue = 
    MINX(shift_table, shift_table[DaysOn])
    var _testValue =
    Value(SELECTEDVALUE(dimDate[Date]) - _shiftEffectDate)
    var _mod =
    MOD(_testValue, _modValue)
    var _shiftName = 
    "#FFB6C1"//MINX(shift_table, shift_table[Name])
    var _testDate = 
    SELECTEDVALUE(dimDate[Date])
    var _offCount = 
    COUNTROWS(FILTER(vacationTable, vacationTable[Name] = _employee && vacationTable[Date] = _testDate))
    Return
    IF(
        _testValue >= 0,
        IF(_mod>=_comparisonValue,_shiftName,IF(_offCount>0,"#fed70d" ,"")),
        ""
    )

    You will end up with...

     

11 Replies

  • Here is a pbix file that hopefully gets you pointed in the right direction. It will not be the final answer for you, but should get you started.

     

    EDIT: Uploaded edited pbix to correct error in measure.

    • coochy5's avatar
      coochy5
      Icon for Helper II rankHelper II

      Hi,

      Thanks for the response, and forgive my tardiness in responding back.

      I see what you've achieved in your sample - never quite works out for me - really unsure why.

      Only real difference I see between your version and mine, I how the calendar is created (mine is based on a min and max of a worker vacation data set) - I had applied the same conditional formatting to the IsOn measure.

       

      This is what I end up with.

       

      Can I supply some test data for you ?  

       

      • coochy5's avatar
        coochy5
        Icon for Helper II rankHelper II

        Just for clarity - I hope :

        Vacations are recorded events (dates) - in a worker vacation table.

        Shift days off - need to be calculated.

        Trying to combine both of these into a matrix visualisation.

         

        Have mocked up the result I'm looking for in excel - sample names/titles etc - real dates, real schedules.

         

         

        This is the data I've used to achieve the mock up:

        Vacation days:

         

        Name

        TitleBaseIdDivisionIdDateTimeTypeWorkScheduleCalendarRotationCrew
        Adam FrohlichSupervisor  1GPCCT1/15/2025Unpaid Time Off (Days)15/6 Rotation 2 (Red)15/6Red
        Bob JensenSupervisorSPOEA12/21/2024Vacation (Days)15/6 Rotation 3 (Yellow)15/6Yellow
        Bob JensenSupervisorSPOEA12/22/2024Vacation (Days)15/6 Rotation 3 (Yellow)15/6Yellow
        Brad JensenSupervisor CATCO12/31/2024Vacation (Days)15/6 Rotation 1 (Blue)15/6Blue
        Brett PittsOperator 3IDKMR12/18/2024Unpaid Time Off (Days)15/6 Rotation 2 (Red)15/6Red
        Brian EalesSupervisor 3GPCCT12/29/2024Unpaid Time Off (Days)15/6 Rotation 1 (Blue)15/6Blue
        Cletus TomsOperator 1GPCFR1/8/2025Unpaid Time Off15/6 Rotation 1 (Blue)15/6Blue
        Cletus TomsOperator 1GPCFR1/14/2025Unpaid Time Off15/6 Rotation 1 (Blue)15/6Blue
        Drake BlinderOperator 4MOOMO12/18/2024Unpaid Time Off15/6 Rotation 3 (Yellow)15/6Yellow
        Drake BlinderOperator 4MOOMO12/20/2024Unpaid Time Off15/6 Rotation 3 (Yellow)15/6Yellow
        Dustin Hoff ManSupervisor 2RDCFR1/2/2025Unpaid Time Off (Days)15/13 Rotation 1 (Magenta)15/13Magenta
        Enid BlytonSupervisor 1RDCFR12/23/2024Unpaid Time Off (Days)15/13 Rotation 2 (Pink)15/13Pink
        Enid BlytonSupervisor 1RDCFR12/27/2024Unpaid Time Off (Days)15/13 Rotation 2 (Pink)15/13Pink
        Eranda SamuelOperator 3HNTFR12/28/2024Unpaid Time Off15/6 Rotation 2 (Red)15/6Red
        Eranda SamuelOperator 3HNTFR12/29/2024Unpaid Time Off15/6 Rotation 2 (Red)15/6Red
        Fred BloggsOperator 1PODSA12/25/2024Parental (Days)15/6 Rotation 2 (Red)15/6Red
        Fred BloggsOperator 1PODSA12/27/2024Parental (Days)15/6 Rotation 2 (Red)15/6Red
        Mowgli GeneralOperator 2GPCCT12/21/2024Unpaid Time Off22/13 Rotation 5 (Teal)22/13Teal
        Mowgli GeneralOperator 2GPCCT12/22/2024Unpaid Time Off22/13 Rotation 5 (Teal)22/13Teal
        Plumber BobSupervisor 1RDCFR12/29/2024Unpaid Time Off (Days)15/6 Rotation 2 (Red)15/6Red
        Robert BealesSupervisor 3GPCCT12/18/2024Unpaid Time Off (Days)15/6 Rotation 1 (Blue)15/6Blue
        Robert BealesSupervisor 3GPCCT12/23/2024Unpaid Time Off (Days)15/6 Rotation 1 (Blue)15/6Blue
        Rough ApprenticeSupervisor 2RDCCT12/20/2024Unpaid Time Off (Days)15/6 Rotation 3 (Yellow)15/6Yellow
        Sean EwesOperator 2HITNM12/20/2024Unpaid Time Off15/6 Rotation 3 (Yellow)15/6Yellow
        Sean EwesOperator 2HITNM12/22/2024Unpaid Time Off15/6 Rotation 3 (Yellow)15/6Yellow