Forum Discussion
Compare dates within same department, same ID, different status
- Anonymous2 years ago
Hi bottos
Please try this:
First of all, I create 2 table with dax:
Table 2 = CALCULATETABLE ( SELECTCOLUMNS ( 'Table', "Department1", 'Table'[Department], "Employee1", 'Table'[Employee ID], "Pre-StartDate", 'Table'[Start Date] ), 'Table'[Status] = "Pre" )Table 3 = CALCULATETABLE ( SELECTCOLUMNS ( 'Table', "Department2", 'Table'[Department], "Employee2", 'Table'[Employee ID], "In-endDate", 'Table'[End Date] ), 'Table'[Status] = "In" )Then create a new table:
Table 4 = CROSSJOIN('Table 2','Table 3')Then add a calculate column:
diff = IF ( 'Table 4'[Department2] = 'Table 4'[Department1], DATEDIFF ( 'Table 4'[In-endDate], 'Table 4'[Pre-StartDate], DAY ) )The result is as follow:
The measure:
count = CALCULATE ( COUNTROWS ( 'Table 4' ), FILTER ( ALLSELECTED ( 'Table 4' ), 'Table 4'[diff] > 30 ) )The result of the sample data is zero.
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi bottos
Given you sample data, what is your expected result? Which row is to be compared against which row? Count how many times it will happen based on what date - today, selected date?
Hi! I have to compare each row that has the status "Per" with every row that has the status "In"; for each comparison, I need to also compare if the Start Date field of the "Pre" row is 30 days more than the End Date of the "In" row. If it is, I need to flag it, and count it in the end.