Forum Discussion
dnsia
Helper II
5 years agoHow to calculate date diff between two rows and columns
Hi all,
Please help.
| BL No | Container No | Load | Discharge | DCHF | TRFF | RCVF | SSTR | SNTC | RCVE | ||
| BL0001 | CONT0001 | PORT A | PORT D | 6/1/2020 4:12 | 6/1/2020 10:50 | 6/8/2020 15:12 | |||||
| BL0001 | CONT0001 | PORT A | PORT D | 6/5/2020 10:03 | |||||||
| BL0002 | CONT0002 | PORT A | PORT D | 6/1/2020 4:12 | 6/1/2020 10:50 | 6/5/2020 11:56 | |||||
| BL0002 | CONT0002 | PORT A | PORT D | 6/4/2020 15:47 | |||||||
| BL0003 | CONT0003 | PORT A | PORT D | 6/1/2020 4:12 | 6/1/2020 9:40 | 6/10/2020 10:46 | |||||
| BL0003 | CONT0003 | PORT A | PORT D | 6/5/2020 13:50 |
I need to calculate date difference for the following
1. DEM Column (in Days) = SNTC and DCHF columns of the same BL Number and Container Number (ie. BL0001 DEM is 4 -- date diff bet 6/5/2020 10:03 and 6/1/2020 4:12).
2. DET Column (in Days) = RCVE and SNTCcolumns of the same BL Number and Container Number (ie. BL0001 DET is 3 -- date diff bet 6/8/2020 15:12 and 6/5/2020 10:03).
| BL No | Container No | Load | Discharge | DCHF | TRFF | RCVF | SSTR | SNTC | RCVE | Dem | Det | ||
| BL0001 | CONT0001 | PORT A | PORT D | 6/1/2020 4:12 | 6/1/2020 10:50 | 6/8/2020 15:12 | 3 | ||||||
| BL0001 | CONT0001 | PORT A | PORT D | 6/5/2020 10:03 | 4 | ||||||||
| BL0002 | CONT0002 | PORT A | PORT D | 6/1/2020 4:12 | 6/1/2020 10:50 | 6/5/2020 11:56 | 1 | ||||||
| BL0002 | CONT0002 | PORT A | PORT D | 6/4/2020 15:47 | 3 | ||||||||
| BL0003 | CONT0003 | PORT A | PORT D | 6/1/2020 4:12 | 6/1/2020 9:40 | 6/10/2020 10:46 | 5 | ||||||
| BL0003 | CONT0003 | PORT A | PORT D | 6/5/2020 13:50 | 4 |
dnsia
Here are the two columns that you need to add:Dim = var __bilno = [BL No] var __sntc = MAXX( FILTER( table11 , Table11[BL No] = __bilno ) , Table11[SNTC]) var __dchf = MAXX( FILTER( table11 , Table11[BL No] = __bilno ) , Table11[DCHF]) return IF( Table11[SNTC] <> BLANK() , DATEDIFF( __dchf, __sntc , DAY ) )Det = var __bilno = [BL No] var __rcve = MAXX( FILTER( table11 , Table11[BL No] = __bilno ) , Table11[SNTC]) var __dchf = MAXX( FILTER( table11 , Table11[BL No] = __bilno ) , Table11[RCVE]) return IF( Table11[RCVE] <> BLANK() , DATEDIFF( __rcve, __dchf , DAY ) )
2 Replies
- Fowmy
Super User
dnsia
Here are the two columns that you need to add:Dim = var __bilno = [BL No] var __sntc = MAXX( FILTER( table11 , Table11[BL No] = __bilno ) , Table11[SNTC]) var __dchf = MAXX( FILTER( table11 , Table11[BL No] = __bilno ) , Table11[DCHF]) return IF( Table11[SNTC] <> BLANK() , DATEDIFF( __dchf, __sntc , DAY ) )Det = var __bilno = [BL No] var __rcve = MAXX( FILTER( table11 , Table11[BL No] = __bilno ) , Table11[SNTC]) var __dchf = MAXX( FILTER( table11 , Table11[BL No] = __bilno ) , Table11[RCVE]) return IF( Table11[RCVE] <> BLANK() , DATEDIFF( __rcve, __dchf , DAY ) )- dnsia
Helper II
This is working fine! Thank you so much for your help!