Forum Discussion
Calculating time between consecutive calls
Hey all,
I am pretty new to Power BI and saw some similar forums to my question, but still haven't been able to figure out how to calculate the time between calls for specific callers in my dataset. Here is a snapshot of the data. I realize that the talk time is given, but I am interested in knowing the total time between consecutive calls. Additionally, I would like to be able to calculate the idle time so I know how long the callers are idling between calls. I tried to color the rows that should be calculated together. I would like another set of columns to calculate the time between calls and idle time. I hope I made this clear enough, thank you!
Index From Date/Time Talk time Idle Time Time Between Calls
| 1 | Person B | 10/20/2021 01:01 pm | 0 | ||
| 2 | Person B | 10/20/2021 01:02 pm | 11 | ||
| 3 | Person C | 10/20/2021 01:03 pm | 582 | ||
| 4 | Person B | 10/20/2021 01:03 pm | 16 | ||
| 5 | Person B | 10/20/2021 01:04 pm | 60 | ||
| 6 | Person D | 10/20/2021 01:05 pm | 5 | ||
| 7 | Person E | 10/20/2021 01:05 pm | 56 | ||
| 8 | Person B | 10/20/2021 01:05 pm | 117 | ||
| 9 | Person D | 10/20/2021 01:07 pm | 56 | ||
| 10 | Person E | 10/20/2021 01:07 pm | 56 | ||
| 11 | Person E | 10/20/2021 01:10 pm | 3 |
Thanks!
4 Replies
- amitchandakSuper User
schwar29 , the expected output is not very clear .
You can diff between two call from same person like, in a new colum
Datediff(maxx(filter(Table, [From] = earlier([From]) && [Date/Time] <earlier([Date/Time])),[Date/Time]), [Date/Time], second)
- v-chenwuz-msftCommunity Support
Hi schwar29 ,
Can you explain why the eighth row is not colored blue. There is no way to calculate by color in power bi. You should mark by data or string instead of color.
Please give some example for Idle Time and Time Between Calls, or calculation logic.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- schwar29New Member
Thanks for your response! I did not color the 8th row blue because it wouldn't be part of the calculations for any of the table that is shown. For example, time between calls for Person B in row 4 and row 5 would be the difference between the two times. However, with row 8, we would have to know the next time a call was made by Person B. Technically I could have colored it blue, but I was thinking about the calculation being between a pair of two consecutive times, and then calculating the difference between them. Does that make sense?
- v-chenwuz-msftCommunity Support
Hi schwar29 ,
Try thes measures.
Idle Time = VAR _SameFromTable = FILTER( 'Table', [Index] <= EARLIER( 'Table'[Index] ) && [From] = EARLIER( 'Table'[From] ) ) VAR _LastTalkTime = CALCULATE( LASTNONBLANK( 'Table'[Talk time], 1 ), FILTER( 'Table', [Index] < EARLIER( 'Table'[Index] ) && [From] = EARLIER( 'Table'[From] ) ) ) VAR _CurrentTalkTime = [Talk time] VAR _IfFirstCall = IF( ISODD( MOD( COUNTROWS( _SameFromTable ), 2 ) ), _CurrentTalkTime, _CurrentTalkTime + _LastTalkTime ) RETURN _IfFirstCallTime Between Calls = VAR _SameFromTable = FILTER( 'Table', [Index] <= EARLIER( 'Table'[Index] ) && [From] = EARLIER( 'Table'[From] ) ) VAR _LastDateTime = CALCULATE( LASTNONBLANK( 'Table'[Date/Time], 1 ), FILTER( 'Table', [Index] < EARLIER( 'Table'[Index] ) && [From] = EARLIER( 'Table'[From] ) ) ) VAR _CurrentDateTime = [Date/Time] VAR _IfFirstCall = IF( ISODD( MOD( COUNTROWS( _SameFromTable ), 2 ) ), 0, _CurrentDateTime - _LastDateTime ) VAR _Time = FORMAT( _IfFirstCall, "hh:nn:ss AMPM" ) RETURN MINUTE( _Time ) + HOUR( _Time ) * 60I setted the first call as zero in Time Between Calls.
Pbix in the end.
Best RegardsCommunity Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.