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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
coochy5
Helper II
Helper II

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"
)))
 
 
coochy5_0-1734460313834.png

Still unable to upload pbix....

 
Hoping someone can help ???
1 ACCEPTED SOLUTION

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...

jgeddes_0-1734635265264.png

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

11 REPLIES 11
jgeddes
Super User
Super User

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.

jgeddes_0-1734471439097.png

 

EDIT: Uploaded edited pbix to correct error in measure.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.

coochy5_0-1734631129254.png

 

Can I supply some test data for you ?  

 

I used the data you posted and amended the pbix. Hope this helps.

jgeddes_0-1734633495593.png

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





ok, ok, ok !  that's fantastic....and almost there - can I go for one more ask ???

on the matrix itself, there's only 2 colours in play - for vacation/other, and shift days off - I don't need the shift days off in the actual crew colour.....

 

I thought it's handled in the 'isOff' measure - so I replaced "black" with a hex colour, but don't easily interpret where to change the shift colour - is that possible ???

 

Colours I need are :

vacay (booked day off)  "#fed70d"
IsShiftOffDay "#FFB6C1"

 

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...

jgeddes_0-1734635265264.png

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Gosh, I've broken it again !

I've tried to incorporate with prod data - so have tinkered with the isOff and isOn measures (just substituting the table names), and added to the dimDate table (just more columns) - and I think I've replicated all....but end result is that whilst vacations plot correctly, all shift schedules seem to start and end of the same dates.

 

Any idea what's going on here ?

 

coochy5_0-1734637724988.png

In the sample data set - shift off days should be:

Red off shift 12/19-12/24

Blue off shift 01/02 - 01/07

Yellow off shift - 12/26-12/31

Make sure the relationships are still valid for the new table(s) you are using.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





that was the issue !

 

Really - I can't thank you enough !

 

Looks great !

 

coochy5_0-1734645308928.png

 

fantastic !

thank you very much !

Looks like what I need exactly !

I'll run through the changes to prod let you know how it goes !

 

Many thanks again for your assistance !

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.

 

coochy5_1-1734631258303.png

 

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

The shift schedules would be generated from this data:

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)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.