Forum Discussion
DSiffredi
Microsoft Employee
3 years agoHow 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...
- 3 years ago
You need to perform two joins forEach Date=>Lead ∪ Backup and Bakup∪Lead 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 - 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!
ThxAlot
Super User
3 years ago
Chk =
VAR __dt = AGMT[date]
VAR __ld = AGMT[lead]
VAR __bk = AGMT[backup]
RETURN
NOT ISEMPTY(
FILTER(
AGMT,
AGMT[date] = __dt && ( AGMT[lead] = __bk || AGMT[backup] = __ld )
)
)
For fun only, a showcase of powerful Excel formula,
=COUNT(0/(([date]=[@date])*(([backup]=[@lead])+([lead]=[@backup]))))>0