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

Looking for DAX assistance to combine vacation/shift days off in same calendar (matrix visualisation

Hi all,

Looking for some assistance on a task that is making me question my sanity (of perhaps starting the project).

Replacing an older C# app.

 

Need to a calender (matrix view) with booked days off combined with rotation days off.

The data source for the vacations is a WorkDay table - sample data attached.

 

6 distinct rotation schedules & 8 distinct crews (colours).

 

The crew colours are the differentiator for the days off - 15/6 red would not be off at the same time as 15/6 yellow.

 

This, cannot be a correct result for example - all red crew would have the same shift days off.

coochy5_0-1732570026012.png

 

I'm having a challenge getting the rotation schedules and crews (colours) mapping on the matrix correctly - and that's prior to adding the vacation days off - which are also a nightmare.

 

I do have a version of this report out in production - but that's only with the vacation days - that's working a charm, but I cannot get the shift days off calculated correctly.

 

This is what I am trying to replicate:

coochy5_1-1732570275971.png

 

 

Any help is graciously received !

 

(adding a link to my sample pbix)

https://drive.google.com/file/d/1hADMpk_o6MVbxUDvjD5cRBv0YZinQY8D/view?usp=drive_link 

 

Here's my worker data, in a table...

 

NameLastNameFirstNameWD_IDActiveTitleDivisionIdBaseIdDateTimeTypeWorkScheduleCalendarRotationCrew
Owen MoneyMoneyOwen2161Supervisor  3EASPO1/19/2025Unpaid Time Off (Days)Day Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Fred BloggsBloggsFred58601Supervisor  2MOMOO11/28/2024Unpaid Time Off (Days)Day Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Fred BloggsBloggsFred58601Supervisor  2MOMOO11/29/2024Unpaid Time Off (Days)Day Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Fred BloggsBloggsFred58601Supervisor  2MOMOO11/30/2024Unpaid Time Off (Days)Day Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Fred BloggsBloggsFred58601Supervisor  2MOMOO1/21/2025Unpaid Time Off (Days)Day Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Fred BloggsBloggsFred58601Supervisor  2MOMOO4/18/2025Unpaid Time Off (Days)Day Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Dog BarkerBarkerDog21011Operator 4NMHIT12/29/2024Unpaid Time OffDay Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Dog BarkerBarkerDog21011Operator 4NMHIT11/25/2024Unpaid Time OffDay Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Dog BarkerBarkerDog21011Operator 4NMHIT11/26/2024Unpaid Time OffDay Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Dog BarkerBarkerDog21011Operator 4NMHIT12/30/2024Unpaid Time OffDay Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Dog BarkerBarkerDog21011Operator 4NMHIT11/27/2004Unpaid Time OffDay Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Dog BarkerBarkerDog21011Operator 4NMHIT12/31/2024Unpaid Time OffDay Rate / Bulker - 15/6 Rotation 2 (Red)15/6Red
Will RodgersRodgersWill99611Operator Frac Blender 4MRIDK12/29/2024Unpaid Time OffDay Rate / Bulker - 15/13 Rotation 1 (Blue)15/13Blue
Will RodgersRodgersWill99611Operator Frac Blender 4MRIDK12/10/2024Unpaid Time OffDay Rate / Bulker - 15/13 Rotation 1 (Blue)15/13Blue
Will RodgersRodgersWill99611Operator Frac Blender 4MRIDK12/11/2024Unpaid Time OffDay Rate / Bulker - 15/13 Rotation 1 (Blue)15/13Blue
Kathy FingerFingerKathy22231Assistant ExecutiveCOCAT12/24/2024Vacation (Days)Day Rate / Bulker - 15/6 Rotation 4 (Purple)15/6Purple
Kathy FingerFingerKathy22231Assistant ExecutiveCOCAT12/30/2024Vacation (Days)Day Rate / Bulker - 15/6 Rotation 4 (Purple)15/6Purple
Sean PottsPottsSean103411Tech IISAPOD12/17/2024Vacation (Days)22/13 (Black)22/13Black
Sean PottsPottsSean103411Tech IISAPOD12/18/2024Vacation (Days)22/13 (Black)22/13Black
Sean PottsPottsSean103411Tech IISAPOD1/2/2025Vacation (Days)22/13 (Black)22/13Black
Sean PottsPottsSean103411Tech IISAPOD12/16/2024Vacation (Days)22/13 (Black)22/13Black
Brianna WilliamsWilliamsBrianna141Supervisor 1EASPO11/29/2024Unpaid Time Off (Days)Day Rate / Bulker - 15/6 Rotation 3 (Yellow)15/6Yellow
Nicky FasterhausFasterhausNicky12651Operator 1GPCTC1/1/2025Unpaid Time Off (Days)Day Rate / Bulker - 15/6 Rotation 3 (Yellow)15/6Yellow

 

 

I have this in a calendar table:

Value_per_day =
LEFT (
    MAXX (
        FILTER (
            ALLSELECTED ( 'Worker_Vacay' ),
            'Worker_Vacay'[Date] = MAX ( 'Calendar'[Date] )
                && 'Worker_Vacay'[Name] = MAX ( 'Worker_Vacay'[Name] )
        ),
        'Worker_Vacay'[TimeType]
    ),
    1
)
 
and I have this, to calculate whether the day is a shift on or off day.
IsShiftOffDayMeasure =
VAR RotationDaysOn = VALUE(LEFT(SELECTEDVALUE('Worker_Vacay'[Rotation]), FIND("/", SELECTEDVALUE('Worker_Vacay'[Rotation])) - 1))
VAR RotationDaysOff = VALUE(RIGHT(SELECTEDVALUE('Worker_Vacay'[Rotation]), LEN(SELECTEDVALUE('Worker_Vacay'[Rotation])) - FIND("/", SELECTEDVALUE('Worker_Vacay'[Rotation]))))
VAR StartDate =
    CALCULATE(
        MIN('Worker_Vacay'[Date]),
        ALLEXCEPT('Worker_Vacay', 'Worker_Vacay'[Crew], 'Worker_Vacay'[Name])  
    )
VAR DaysSinceStart = DATEDIFF(StartDate, SELECTEDVALUE('Calendar'[Date]), DAY)
VAR CycleDays = RotationDaysOn + RotationDaysOff
RETURN
IF(
    MOD(DaysSinceStart, CycleDays) >= RotationDaysOn,
    1,  // offday
    0   // workday
)
5 REPLIES 5
coochy5
Helper II
Helper II

Hi.  This is great.  It conceptually works !  Can I ask for some further advice ?  The days on/off schedule varies by for the crew colour and rotations - and the calendars have different commencement dates.  I'm not sure, in the measure you supplied, how the start date of each rest period is calculated.  How should I incorporate the shift patterns - a seperate table referenced in the measure ?

 

Example data:

IdNameDaysOnDaysOffColorEffectiveDateIsActiveWorkdayName
1Red156#ff000010/23/20241Day Rate / Bulker - 15/6 Rotation 2 (Red)
2Yellow156#dede002/15/20171Day Rate / Bulker - 15/6 Rotation 3 (Yellow)
3Blue156#0000ff2/22/20171Day Rate / Bulker - 15/6 Rotation 1 (Blue)
4Teal2213#008B8B5/30/20181Day Rate / Bulker / Hourly - 22/13 Rotation 5 (Teal)
5Orange2213#ff7f275/9/20181Day Rate / Bulker / Hourly - 22/13 Rotation 2 (Orange)
6Purple2213#a349a45/2/20181Day Rate / Bulker / Hourly - 22/13 Rotation 1 (Purple)
7Brown2213#b97a575/23/20181Day Rate / Bulker / Hourly - 22/13 Rotation 4 (Brown)
8Grey2213#7080905/16/20181Day Rate / Bulker / Hourly - 22/13 Rotation 3 (Grey)
9Magenta1513#f966f94/1/20201Salary - 15/13 Rotation 1 (Magenta)
10Pink1513#fe7c894/15/20201Salary - 15/13 Rotation 2 (Pink)
Anonymous
Not applicable

Hi, @coochy5 
 

Thank you for your prompt response.

 

I have imported your new table as the 'color' table:

vlinyulumsft_0-1732785275667.png

Next, you can replace the value section of the matrix visual with the following measures:

 

Colour Format1 = 
IF (
    [Value_per_day] = "V",
    "#fed70d",
    IF (
        [Value_per_day] = "U",
        "#fed68d",
        IF (
            [IsShiftOffDayMeasure] = 1,
            VAR cc =
                MAX ( 'FACT'[Crew] )
            RETURN
                CALCULATE ( MAX ( 'color'[Color] ), FILTER ( 'color', 'color'[Name] = cc ) )
        )
    )
)

 

Then, adjust its colour settings:

vlinyulumsft_3-1732785528631.png

vlinyulumsft_2-1732785312452.png

vlinyulumsft_0-1732785382385.png

Here are the final results:

vlinyulumsft_2-1732785520053.png

Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
 

Best Regards,

Leroy Lu

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

Hi.

Thanks again for your kind assistance.  I think I'm unintentionally misleading here, or not being clear on the requirement.

 

Crew members are allocated to a shift schedule - eg 15/6, 22/13 - 15 days on, 6 off, 22 days on, 13 off etc.

The crew colour denotes the rotation - so that the rotations are offset.  

Lots of crew will be on a 15/6 shift schedule, but will be on different rotations, so they are not off at the same time.  

I've tried to incorporate your suggestions into my dev report - and it shows all crew colours off at the same time.

Not sure how I am getting this so wrong!

The measures - I believe, are identical - just changed table names.

I've added the same 'Color' table that you have used in your version back to me.

Curiously - I show no shift days off prior to 12-Dec-24, which is also not correct - in my live dataset.  Some crews are already off.

 

Lastly - on the values in the matrix grid - I only need to display 2 colours - the shift days off would all be the same colour, and vacation/other time off will be the second colour.

 

Here's my result:

 

coochy5_0-1732812176471.png

 

 

 

I wonder if it is worthwhile to create a new shift schedule table.  Here's what I think it would look like - with the next set of effective dates for Dec 2024.  (removed some schedules for ease)

 

IdNameDaysOnDaysOffEffectiveDateIsActiveWorkdayNameNewStartDate(ShiftOn)NextOffDate
1Red15610/23/20241Day Rate / Bulker - 15/6 Rotation 2 (Red)4-Dec-2419-Dec-24
2Yellow1562/15/20171Day Rate / Bulker - 15/6 Rotation 3 (Yellow)11-Dec-2426-Dec-24
3Blue1562/22/20171Day Rate / Bulker - 15/6 Rotation 1 (Blue)27-Nov-2412-Dec-24
4Magenta15134/1/20201Salary - 15/13 Rotation 1 (Magenta)4-Dec-2419-Dec-24
5Pink15134/15/20201Salary - 15/13 Rotation 2 (Pink)18-Dec-242-Jan-25

Hi,

Were you able to offer any further insights into this ?

I managed to get the 2 time off periods colours sorted out (vacation/other & shift days off), but am unable to get the shift days off correctly represented in the offset form.

All shift days off seem to follow the same pattern, which is not correct, and not the result you achieved.

 

This....is not the correct result...(from my prod instance)

 

coochy5_1-1733164746414.png

This particular group, should look like this, for the date periods...

 

coochy5_2-1733164828073.png

 

Any further assistance is greatly appreciated !

 

Am hoping this latest attempt to share the .pbix is successful.

color_test_calendar.pbix

 

Anonymous
Not applicable

Hi, @coochy5 

Firstly, regarding the PBIX file you shared, I am currently unable to access it due to privacy protocol issues. However, I have reviewed your previous questions and obtained the PBIX file related to the relevant responses.

Therefore, if your data requirements have been updated, please refer to the following link:

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Solved: How to upload PBI in Community - Microsoft Fabric Community

 

When uploading a file, please be careful to delete sensitive information.

 

Based on my understanding of your question, you require the same rest period for the same Crew. Please replace the DAX with the following content:

IsShiftOffDayMeasure = 
VAR Rotation =
    SELECTEDVALUE ( 'FACT'[Rotation] )
VAR RotationDaysOn =
    VALUE ( LEFT ( Rotation, FIND ( "/", Rotation ) - 1 ) )
VAR RotationDaysOff =
    VALUE ( RIGHT ( Rotation, LEN ( Rotation ) - FIND ( "/", Rotation ) ) )
VAR StartDate =
    CALCULATE ( MIN ( 'FACT'[Date] ), ALLEXCEPT ( 'FACT', 'FACT'[Crew] ) )
VAR DaysSinceStart =
    DATEDIFF ( StartDate, SELECTEDVALUE ( 'Calendar'[Date] ), DAY )
VAR CycleDays = RotationDaysOn + RotationDaysOff
RETURN
    IF ( MOD ( DaysSinceStart, CycleDays ) >= RotationDaysOn, 1, 0 )

Here are the final results:

vlinyulumsft_0-1732608228156.png

If I have misunderstood your requirements, I would appreciate your prompt correction, along with a diagram to illustrate your needs.

 

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

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.