Forum Discussion
Reaction-/Resolution time calculations (with a twist)
This works! Any hints on how I can get output in Days and hours instead of full hours?
Thank you very much both for contributing!
I'm experimenting with formula found here on forum. I changed austinsense measure to give seconds but with my Resolution-Display-measure function is calculating only full days. Any help on this? My data looks like following:
Created and Modified columns are correct type:
Reaction/Resolution -measures use following function:
Reactionmeasure-seconds =
DATEDIFF (
MIN ( Tickets[Created] );
CALCULATE (
MIN ( Tickets[Muokattu] );
FILTER ( Tickets; Tickets[Muokattu] <> MIN ( Tickets[Created] ) )
);
SECOND
)
------
Resolutionmeasure-seconds =
DATEDIFF (
MIN ( Tickets[Created] );
CALCULATE (
MAX ( Tickets[Muokattu] );
FILTER ( Tickets; Tickets[Muokattu] <> MIN ( Tickets[Created] ) )
);
SECOND
)
Resolution-Display =
FORMAT (
INT (
IF (
MOD ( [Resolutionmeasure-seconds]; 60 ) = 60,0;
MOD ( [Resolutionmeasure-seconds]; 60 )
)
+ IF (
MOD ( INT ( [Resolutionmeasure-seconds] / 60 ); 60 )
= 60,0;
MOD ( INT ( [Resolutionmeasure-seconds] / 60 ); 60 )
* 100
)
+ INT ( [Resolutionmeasure-seconds] / 3600 )
* 10000
);
"0:00:00"
)
- Anonymous9 years agoNot applicable
Little error that I notice myself in my last post. Currently the Resolution-Display shows 375:00:00. We can see that it shows full hours as days.
1351581 seconds / 60
approx 22526,35 minutes / 60
approx 375,44 Hours /24
approx 15,64 Days
- Anonymous9 years agoNot applicable
Getting forward!
Now I'm getting all the data with solution by Jon Gallant but the formula displays HH:MM:SS. If someone could help converting this to DD:HH:MM and we would be all set :)
Resolution-Display2 has a following function:
Resolution-Display2 =
// Duration formatting
// * @konstatinos 1/25/2016
// * Given a number of seconds. returns a format of "hh:mm:ss"
//
// We start with a duration in number of seconds
VAR Duration = [Resolutionmeasure-seconds] // There are 3.600 seconds in an hour
VAR Hours =
INT ( Duration / 3600 ) // There are 60 seconds in a minute
VAR Minutes =
INT ( MOD ( Duration - ( Hours * 3600 ); 3600 ) / 60 ) // Remaining seconds are the remainder of the seconds divided by 60 after subtracting out the hours
VAR Seconds =
ROUNDUP ( MOD ( MOD ( Duration - ( Hours * 3600 ); 3600 ); 60 ); 0 ) // We round up here to get a whole number
// These intermediate variables ensure that we have leading zero's concatenated onto single digits
// Hours with leading zeros
VAR H =
IF ( LEN ( Hours ) = 1; CONCATENATE ( "0"; Hours ); CONCATENATE ( ""; Hours ) ) // Minutes with leading zeros
VAR M =
IF (
LEN ( Minutes ) = 1;
CONCATENATE ( "0"; Minutes );
CONCATENATE ( ""; Minutes )
) // Seconds with leading zeros
VAR S =
IF (
LEN ( Seconds ) = 1;
CONCATENATE ( "0"; Seconds );
CONCATENATE ( ""; Seconds )
) // Now return hours. minutes and seconds with leading zeros in the proper format "hh:mm:ss"
RETURN
CONCATENATE (
H;
CONCATENATE ( ":"; CONCATENATE ( M; CONCATENATE ( ":"; S ) ) )
) - Anonymous9 years agoNot applicable
And I got it to work. I'm just dismissing the seconds here. No need to do Roundup to minutes as it is close enough. If someone want's make the function smarter (shorter) please do but this works for me.
Resolution-Display3 =
VAR Duration = [Resolutionmeasure-seconds] // 86400 seconds in a day
VAR Days =
INT ( Duration / 86400 ) // 3600 seconds in a hour
VAR Hours =
INT ( MOD ( Duration - ( days * 3600 ); 3600 ) / 60 ) // There are 60 seconds in a minute
VAR Minutes =
INT ( MOD ( Duration - ( Hours * 3600 ); 3600 ) / 60 ) // Remaining seconds are the remainder of the seconds divided by 60 after subtracting out the hours
VAR Seconds =
ROUNDUP ( MOD ( MOD ( Duration - ( Hours * 3600 ); 3600 ); 60 ); 0 ) // We round up here to get a whole number
// These intermediate variables ensure that we have leading zero's concatenated onto single digits
// Hours with leading zeros
VAR D =
IF ( LEN ( Days ) = 1; CONCATENATE ( "0"; Days ); CONCATENATE ( ""; Days ) )
VAR H =
IF ( LEN ( Hours ) = 1; CONCATENATE ( "0"; Hours ); CONCATENATE ( ""; Hours ) ) // Minutes with leading zeros
VAR M =
IF (
LEN ( Minutes ) = 1;
CONCATENATE ( "0"; Minutes );
CONCATENATE ( ""; Minutes )
) // Seconds with leading zeros
VAR S =
IF (
LEN ( Seconds ) = 1;
CONCATENATE ( "0"; Seconds );
CONCATENATE ( ""; Seconds )
) // Now return hours. minutes and seconds with leading zeros in the proper format "hh:mm:ss"
RETURN
CONCATENATE (
D;
CONCATENATE ( ":"; CONCATENATE ( H; CONCATENATE ( ":"; M ) ) )
) - Anonymous9 years agoNot applicable
I had to take a step back. None of the previous solutions give the correct timestamps. I now have a workin logic and functions (almost)
I used calculated COLUMNwhich will find the latest modification date from Modified -column for every ID for RESOLUTION time.
For REACTION time we use the same method but look for earliest timestamp.
Resolution-Timestamp =
CALCULATE(
MAX(
'Tukipyynnot'[Muokattu]);
FILTER('Tukipyynnot';'Tukipyynnot'[ID] = EARLIER('Tukipyynnot'[ID])
)
)As you can see we now have a column with correct information on every row and can easily take the correct data out with filters. Works great with resolution time and with minimal code.
With response however I still have one obstacle. The earliest timestamp is the same as ticket creation (column "luotu") date. I need to leave that out from calculation so I can get the first timestamp with actions made to new ticket. How can I achieve this in function?
Reaction-Timestamp =
CALCULATE(
MIN(
'Tukipyynnot'[Muokattu]);
FILTER('Tukipyynnot';'Tukipyynnot'[ID] = EARLIER('Tukipyynnot'[ID])
)
)Thank you for any possible input.