Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello, I hope some can help me, i have a data table with this columns
- TicketID
- Ticket creation date
- Last action
- Date/time of last action
Actions can be things like giving a priority to the ticket or give a solution to the customer. For every action in a ticket a new table row is created.
I want to create something that shows me the average time between the giving a priority to a ticket action and the first action that follows on giving a priority to a ticket. The difficulty is that the action that follows on giving a priority to a ticket varies.
Can someone help me with how to get this done?
Solved! Go to Solution.
Hi @Anonymous,
It looks like there existing more than one records where Action is set to "Set Priority to regular" per Ticket ID. If so, please try below suggestion.
First, add a calculated column in Table1.
Index = RANKX ( FILTER ( 'Table1', Table1[TicketID] = EARLIER ( Table1[TicketID] ) ), Table1[Action date/time], , ASC, DENSE )
Then, add measure [Average] into a card visual.
Timediff = VAR _CurrentActiontime = SELECTEDVALUE ( Table1[Action date/time] ) VAR _NextActiontime = CALCULATE ( SELECTEDVALUE ( Table1[Action date/time] ), FILTER ( ALLEXCEPT ( Table1, Table1[TicketID] ), Table1[Index] = MAX ( Table1[Index] ) + 1 ) ) VAR diff = IF ( SELECTEDVALUE ( Table1[Action] ) = "Set priority to regular", DATEDIFF ( _CurrentActiontime, _NextActiontime, SECOND ), BLANK () ) RETURN diff
Average =
AVERAGEX ( ALLSELECTED ( Table1 ), [Timediff] )
Best regards,
Yuliana Gu
Hi @Anonymous,
It looks like there existing more than one records where Action is set to "Set Priority to regular" per Ticket ID. If so, please try below suggestion.
First, add a calculated column in Table1.
Index = RANKX ( FILTER ( 'Table1', Table1[TicketID] = EARLIER ( Table1[TicketID] ) ), Table1[Action date/time], , ASC, DENSE )
Then, add measure [Average] into a card visual.
Timediff = VAR _CurrentActiontime = SELECTEDVALUE ( Table1[Action date/time] ) VAR _NextActiontime = CALCULATE ( SELECTEDVALUE ( Table1[Action date/time] ), FILTER ( ALLEXCEPT ( Table1, Table1[TicketID] ), Table1[Index] = MAX ( Table1[Index] ) + 1 ) ) VAR diff = IF ( SELECTEDVALUE ( Table1[Action] ) = "Set priority to regular", DATEDIFF ( _CurrentActiontime, _NextActiontime, SECOND ), BLANK () ) RETURN diff
Average =
AVERAGEX ( ALLSELECTED ( Table1 ), [Timediff] )
Best regards,
Yuliana Gu
@v-yulgu-msft this does the trick! Thank you very much for your help!
@AlB also many thanks for all your help!
Hi @Anonymous
Can you post sample data or share the pbix? It'd be easier to help out like that
152111 | 7-1-2019 15:03:09 | Ticket created | 7-1-2019 15:03:09 |
152111 | 7-1-2019 15:03:09 | Set priority to regular | 7-1-2019 15:25:00 |
152111 | 7-1-2019 15:03:09 | Give solution to customer | 7-1-2019 16:01:03 |
152111 | 7-1-2019 15:03:09 | Ticket closed | 7-1-2019 16:02:01 |
@Anonymous
What do you exactly mean by 'giving priority to a ticket'? Is this when 'Action' is set to "Set priority to regular"?
Do you want to see the time between when 'Action' is set to "Set priority to regular" and whatever comes immediately afterwards for a specific TicketID?
Providing an example with your sample data would probably help clarify
@Anonymous
And how would the average have to be calculated exactly? Is it the average of that period of time you just described across all TicketIDs?
@Anonymous
Try this measure in a card visual for instance:
AvgTimeCreation2Priority = VAR _AuxTable = SUMMARIZECOLUMNS ( Table1[TicketID]; "Time2Next"; VAR _CreationTime = VALUES ( Table1[ Ticket created] ) VAR _NextActiontime = FIRSTNONBLANK ( CALCULATETABLE ( VALUES ( Table1[ Action date/time] ); Table1[ Action date/time] > _CreationTime ); 1 ) VAR _TimeDiffMins = ( _NextActiontime - _CreationTime )* 24 * 60 RETURN _TimeDiffMins ) RETURN AVERAGEX ( _AuxTable; [Time2Next] )
where Table1 is the name of your table. Do note that the result is in minutes (ex. 2 mins 30 seconds will show as 2,5). You can convert that into mins:secs format if you so need.
@Anonymous
Sorry, you're right. I misread and was taking the creation time as initial time. This is the updated version. As you see you can use this pattern with minor variations to extract the time period you are interested in.
AvgTimeSetPriority2Next = VAR _AuxTable = SUMMARIZECOLUMNS ( Table1[TicketID]; "Time2Next"; VAR _SetPriorityTime = CALCULATE ( VALUES ( Table1[ Action date/time] ); Table1[Action] = "Set priority to regular" ) VAR _NextActiontime = FIRSTNONBLANK ( CALCULATETABLE ( VALUES ( Table1[ Action date/time] ); Table1[ Action date/time] > _SetPriorityTime ); 1 ) VAR _TimeDiffMins = ( _NextActiontime - _SetPriorityTime ) * 24 * 60 RETURN _TimeDiffMins ) RETURN AVERAGEX ( _AuxTable; [Time2Next] )
@Anonymous
Hmmm... I ran a quick test and it's working fine. Maybe you have more than one row for a TicketID with Action "Set priority to regular"?
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
92 | |
86 | |
85 | |
66 | |
49 |
User | Count |
---|---|
140 | |
113 | |
104 | |
64 | |
60 |