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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
coochy5
Helper II
Helper II

Need to combine vacation table with calculated shift rotation in same calendar in matrix visual

Hi all,

Looking for some DAX assistance here.

I've had prior help with this, for which I am appreciative and it's sooo close, I just need to get it over the line.

Had some challenges with uploading pbix here (yes, followed cloud instructions, but still doesn't seem to work), so going with sample data in tables instead.

 

FACT table - workers with booked days off.  Identifies date and crew (colour) and rotation.  There are many rotations and colours - so only included a small sample set, as it's illustrative of my problem - even though personnel are on the same rotation, they have different crew colours, and would have their shift off days offset from other crews on the same rotation.

 

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
8 REPLIES 8
Anonymous
Not applicable

Hi @coochy5 ,

 

I tried to reproduce your question and there seems to be some problems, how far along are you so far?

 

Best regards,

Adamk Kong

Hi there.

Did I provide enough information ?

Hi.

Thanks for the response.

I'm along, quite far, thanks to previous posts - my last post (https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Looking-for-DAX-assistance-to-combin...) contains a color.pbix, which almost works....

 

Whilst the days off are offset (the pattern is the correct result), they are not calculating correctly - the shift days off are incorrect....

I need the shift days off to calculate from a static effective date - or some assistance how to set them up appropriately.

 

(colour format 1 measure needs to be replaced with:

Colour Format1 =

IF (

    [Value_per_day] = "V",

    "#fed68d",

    IF (

        [Value_per_day] = "U",

        "#fed68d",

        IF (

            [IsShiftOffDayMeasure] = 1,

        "#d0aaaa"

 )

        )

    )

 

I need the shift days off to start from effective dates - in the table attached earlier in this post, but I cannot seem to get them working as expected.

 

(if you replace the colour format1 measure in the color.pbix from the prior post, you should get this result:

 

coochy5_1-1733508357960.png

 

 

 

and in the above result, the crew off days should be

Blue - should be 12-17 Dec inclusive.  Next off days +15 from there, 02-Jan - 07-Jan 2025.

Yellow - should be 26-Dec-31-Dec inclusive.  Next off - 16-Jan - 21-Jan 2025.

Red - should be 19-Dec-24-Dec inclusive.  Next off - 09-Jan - 14-Jan 2025.

 

Please let me know if you need any further info !

coochy5
Helper II
Helper II

Shift Days off needs to be calculated from :

IdNameDaysOnDaysOffColorEffectiveDateIsActiveWorkdayName
1Red156#fed68d10/23/20241Day Rate / Bulker - 15/6 Rotation 2 (Red)
2Yellow156#fed68d2/15/20171Day Rate / Bulker - 15/6 Rotation 3 (Yellow)
3Blue156#fed68d2/22/20171Day Rate / Bulker - 15/6 Rotation 1 (Blue)
4Teal2213#fed68d5/30/20181Day Rate / Bulker / Hourly - 22/13 Rotation 5 (Teal)
5Orange2213#fed68d5/9/20181Day Rate / Bulker / Hourly - 22/13 Rotation 2 (Orange)
6Purple2213#fed68d5/2/20181Day Rate / Bulker / Hourly - 22/13 Rotation 1 (Purple)
7Brown2213#fed68d5/23/20181Day Rate / Bulker / Hourly - 22/13 Rotation 4 (Brown)
8Grey2213#fed68d5/16/20181Day Rate / Bulker / Hourly - 22/13 Rotation 3 (Grey)
9Magenta1513#fed68d4/1/20201Salary - 15/13 Rotation 1 (Magenta)
10Pink1513#fed68d4/15/20201Salary - 15/13 Rotation 2 (Pink)

 

Created a standard calender to use:

Calendar =
Var
    _startDate = min('FACT'[Date])
Var
    _endDate = max('FACT'[Date])
RETURN
    ADDCOLUMNS(
        CALENDAR(_startDate,_endDate)
        ,"Year", YEAR([Date])
        ,"Month", FORMAT([Date], "mmm")
        ,"Month Sort", MONTH([Date])
        ,"Day", Day([Date])
        ,"Day Of Week", WEEKDAY([Date])
        ,"Day Of Week Name", FORMAT([Date], "ddd")
        ,"Week of Year", WEEKNUM([Date])
        ,"DM", FORMAT([Date], "ddd") & " " & Day([Date]) & "-" & FORMAT([Date], "mmm")
        )

 

Measure for shift days:

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 )

Colour Format2 =
IF (
    [Value_per_day] = "V",
    "#fed68d",
    IF (
        [Value_per_day] = "U",
        "#fed68d",
        IF (
            [IsShiftOffDayMeasure] = 1,
            VAR cc =
                MAX ( 'Fact Crew Worker Time Off V1'[Crew] )
            RETURN
                CALCULATE ( MAX ( 'color'[Color] ), FILTER ( 'color', 'color'[Name] = cc ) )
        )
    )
)

this is the result that I am hoping to achieve

(only displaying rotation days off (by crew (colour) - needs to also have any vacation days off).

 

coochy5_0-1733428264289.png

...but ...in production - this is the result I'm actually getting...so is incorrect - suggests all colours are off shift on the same days

coochy5_0-1733430377552.png

 

 

Any further assistance is very much appreciated !

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.