Forum Discussion
WimHenderickx
1 year agoFrequent Visitor
Index
Looking for formula that creates index as in example. Per employee ID it is checked whether between the notifications e.g. Enddate first line and Startdate 2nd line there is a day difference if there...
- 1 year ago
WimHenderickx
Please try now:Order = VAR __CurrStartDate = Table03[StartDate] VAR __PrevEndDate = CALCULATE ( MAX ( Table03[EndDate] ), Table03[EndDate] < __CurrStartDate, ALLEXCEPT ( Table03, Table03[Employe ] ) ) VAR __Result = IF ( ISBLANK ( __PrevEndDate ), 1, IF ( INT ( __CurrStartDate - __PrevEndDate ) <= 1, 0, 1 ) ) RETURN __ResultIndex = VAR __Emp = Table03[Employe ] VAR __StartDate = Table03[StartDate] VAR __Result = CALCULATE ( SUM ( Table03[Order] ), Table03[Employe ] = __Emp, Table03[StartDate] <= __StartDate, REMOVEFILTERS ( table03 ) ) RETURN __Result
WimHenderickx
1 year agoFrequent Visitor
It goes wrong after the second row when there is no gap between the endDate and startdate
| Employe | Startdate | EndDate | Order | Index | Expected |
| 1 | 5-12-2022 | 13-3-2023 | 13-3-2023 | 1 | 1 |
| 1 | 14-3-2023 | 19-3-2023 | 13-3-2023 | 1 | 1 |
| 1 | 20-3-2023 | 10-4-2023 | 19-3-2023 | 2 | 1 |
| 1 | 11-4-2023 | 25-6-2023 | 10-4-2023 | 3 | 1 |
| 1 | 26-6-2023 | 17-1-2024 | 25-6-2023 | 4 | 1 |
| 1 | 18-1-2024 | 31-1-2024 | 17-1-2024 | 5 | 1 |
| 1 | 1-2-2024 | 6-2-2024 | 31-1-2024 | 6 | 1 |
| 1 | 7-2-2024 | 1-3-2024 | 6-2-2024 | 7 | 1 |
| 1 | 1-7-2024 | 31-7-2024 | 31-7-2024 | 8 | 2 |
| 1 | 1-8-2024 | 15-9-2024 | 31-7-2024 | 8 | 2 |
| 1 | 16-9-2024 | 29-10-2024 | 15-9-2024 | 9 | 2 |
| 2 | 16-3-2023 | 20-3-2023 | 20-3-2023 | 1 | 1 |
| 2 | 16-7-2023 | 19-7-2023 | 19-7-2023 | 1 | 1 |
| 3 | 1-4-2024 | 4-4-2024 | 4-4-2024 | 1 | 1 |
| 3 | 5-4-2024 | 9-4-2024 | 4-4-2024 | 1 | 1 |
Fowmy
1 year agoSuper User
WimHenderickx
Should this be 1, 2
| 2 | 16-3-2023 | 20-3-2023 | 20-3-2023 | 1 | 1 |
| 2 | 16-7-2023 | 19-7-2023 | 19-7-2023 | 1 | 1 |
- WimHenderickx1 year agoFrequent Visitor
Yes you are right
- Fowmy1 year agoSuper User
WimHenderickx
Please try now:Order = VAR __CurrStartDate = Table03[StartDate] VAR __PrevEndDate = CALCULATE ( MAX ( Table03[EndDate] ), Table03[EndDate] < __CurrStartDate, ALLEXCEPT ( Table03, Table03[Employe ] ) ) VAR __Result = IF ( ISBLANK ( __PrevEndDate ), 1, IF ( INT ( __CurrStartDate - __PrevEndDate ) <= 1, 0, 1 ) ) RETURN __ResultIndex = VAR __Emp = Table03[Employe ] VAR __StartDate = Table03[StartDate] VAR __Result = CALCULATE ( SUM ( Table03[Order] ), Table03[Employe ] = __Emp, Table03[StartDate] <= __StartDate, REMOVEFILTERS ( table03 ) ) RETURN __Result- WimHenderickx1 year agoFrequent Visitor
Thanks for all your help.