Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Per customer I'm trying to show the first and last date across multiple rows and calculate the difference in days, in case of consecutive contracts.
A contract is consecutive when ValidFrom is the day after previous row ValidTo, of the same Customer. The consecutive contracts have an adjacent serial number starting with C.
The rows in the table are already grouped by Customer with an index number.
Sample table:
Sample table in text format:
| Contract | Customer | Index | ValidFrom | ValidTo |
| C2401 | Joe | 1 | 01-01-1977 | 04-01-2008 |
| C3720 | Joe | 2 | 19-07-2018 | 31-12-2018 |
| C3721 | Joe | 3 | 01-01-2019 | 31-12-2019 |
| C3722 | Joe | 4 | 01-01-2020 | 31-10-2021 |
| C4860 | Joe | 5 | 04-06-2022 | 10-06-2022 |
| C4861 | Joe | 6 | 11-06-2022 | 30-08-2022 |
Expected result:
| Customer | From | To | DateDiff |
| Joe | 19-07-2018 | 31-10-2021 | 1200 |
| Joe | 04-06-2022 | 30-08-2022 | 87 |
Thank you!
Hi @GKJARC ,
Has your problem been solved, if so, please consider Accept a correct reply as the solution or share your own solution to help others find it.
Best Regards
Lucien
| User | Count |
|---|---|
| 52 | |
| 35 | |
| 22 | |
| 17 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 57 | |
| 39 | |
| 21 | |
| 21 |