Forum Discussion
motzplo
8 years agoRegular Visitor
Timediff between rows depending on index
Hello all,
I have the following problem and I hope some of you can help me. I would like to calculate the time difference between two rows, depending on the ID. Time difference between two rows of a different ID is not possible. The time difference should look like the following picture.
Thank you in advance.
Hi motzplo,
Try this formula, please.
Column = VAR currentID = [ID] VAR currentIndex = [Index] VAR nextDatetime = CALCULATE ( MIN ( Table1[Datetime] ), FILTER ( 'Table1', 'Table1'[ID] = currentID && 'Table1'[Index] = currentIndex + 1 ) ) RETURN DATEDIFF ( [Datetime], nextDatetime, MINUTE )Best Regards,
Dale
2 Replies
- v-jiascu-msft
Microsoft Employee
Hi motzplo,
Try this formula, please.
Column = VAR currentID = [ID] VAR currentIndex = [Index] VAR nextDatetime = CALCULATE ( MIN ( Table1[Datetime] ), FILTER ( 'Table1', 'Table1'[ID] = currentID && 'Table1'[Index] = currentIndex + 1 ) ) RETURN DATEDIFF ( [Datetime], nextDatetime, MINUTE )Best Regards,
Dale
- Ashish_Mathur
Super User
Hi,
Try this calculated column formula
=CALCULATE(MIN(Data[Datetime]),FILTER(Data,Data[ID]=EARLIER(Data[ID])&&Data[Datetime]>EARLIER(Data[Datetime])))-[Datetime]
Hope this helps.