Forum Discussion

DSiffredi's avatar
DSiffredi
Icon for Microsoft Employee rankMicrosoft Employee
3 years ago
Solved

How to detect conflicts on the same date - i.e. people going on vacations pointing at eachother

hi team, I have one that I've been scratching my head for quite a bit.  I need to be able to detect conflicts when a person is taking time off pointing to another person that is also taking time off...
  • smpa01's avatar
    smpa01
    3 years ago

    You need to perform two joins forEach Date=>Lead Backup and BakupLead to find the intersection in each. Any join that returns match then it is true

     

     

    fullOuter = 
    VAR dt =
        MAX ( 'Table 1'[date] )
    VAR _lead =
        MAX ( 'Table 1'[lead] )
    VAR _backup =
        MAX ( 'Table 1'[backup] )
    VAR tblOne_1 = { _lead }
    VAR tblOne_2 = { _backup }
    VAR tblTwo_1 =
        SELECTCOLUMNS (
            SUMMARIZE (
                FILTER ( ALL ( 'Table 1' ), 'Table 1'[date] = dt ),
                'Table 1'[backup]
            ),
            "@candidate", [backup] & ""
        )
    VAR tblTwo_2 =
        SELECTCOLUMNS (
            SUMMARIZE (
                FILTER ( ALL ( 'Table 1' ), 'Table 1'[date] = dt ),
                'Table 1'[lead]
            ),
            "@candidate", [lead] & ""
        )
    VAR tblthree_1 =
        GENERATE (
            tblTwo_1,
            VAR one = [@candidate] RETURN FILTER ( tblOne_1, [Value] = one )
        )
    VAR tblthree_2 =
        GENERATE (
            tblTwo_2,
            VAR one = [@candidate] RETURN FILTER ( tblOne_2, [Value] = one )
        )
    VAR ternary_1 =
        COUNTX ( tblthree_1, [@candidate] )
    VAR ternary_2 =
        COUNTX ( tblthree_2, [@candidate] )
    VAR ternary =
        IF ( ternary_1 <> BLANK () || ternary_2 <> BLANK (), 1, 0 )
    RETURN
        ternary

     

     

     

  • DSiffredi's avatar
    DSiffredi
    3 years ago

    simply put , GENIOUS! thank you very much, I had that on my mind but wasn't able to translate it to DAX. thank you very much!