cancel
Showing results for
Did you mean:
Wkbdrguy Frequent Visitor

## Need Help with Time calculation and filters

I'm working with the following calculation to get average broken into days, hours, Minutes.

TTA = Time to Acknowledge

------------------------------------

AVG TTA =

VAR Dur = AVERAGE('Table'[TTA (Seconds)])
VAR DAYS = IF ( Dur >= 1, INT ( Dur / 86400 ), BLANK () )
VAR HOURS = IF ( Dur >= 1, INT( MOD( Dur - ( Days * 86400 ), 86400 ) / 3600))
VAR MINUTES = INT ( MOD( Dur - ( Hours * 3600 ), 3600 ) / 60)

VAR D = IF ( DAYS > 1, FORMAT ( DAYS, "00" ) & "d" )
VAR H = IF ( HOURS > 1, FORMAT ( HOURS, "00" ) & "h")
VAR M = FORMAT ( MINUTES, "00" ) & "m "

RETURN
COMBINEVALUES ( " ", D, H, M )

------------------------------------

Problem i running into is the average time does not change when i use a slicer to filter for different months. I'm thinking that this is due to text within the calculation as the filter works fine when im not trying to break out the calculation to days, hours, and minutes.

1 ACCEPTED SOLUTION

Accepted Solutions
Wkbdrguy Frequent Visitor

## Re: Need Help with Time calculation and filters

Solved: I created 3 separate measures:

 AVG TTA (Days)  =//CALCULATIONSVAR Dur = AVERAGE ( Table[TTA (Sec)] )//Separate TimeVAR DAYS = IF ( Dur >= 1, INT ( Dur / 86400 ), BLANK () )VAR HOURS = IF ( Dur >= 1, INT ( MOD ( Dur - ( Days * 86400 ), 86400 ) / 3600 ), BLANK () )VAR MINUTES = INT ( MOD ( Dur - ( Hours * 3600 ), 3600 ) / 60 )//FormatVAR D =IF ( DAYS > 1, FORMAT ( DAYS, "00" ), BLANK () )RETURND AVG TTA (Hours) =//CALCULATIONSVAR Dur = AVERAGE ( Table[TTA (Sec)] )//Separate TimeVAR DAYS = IF ( Dur >= 1, INT ( Dur / 86400 ), BLANK () )VAR HOURS = IF ( Dur >= 1, INT ( MOD ( Dur - ( Days * 86400 ), 86400 ) / 3600 ), BLANK () )VAR MINUTES = INT ( MOD ( Dur - ( Hours * 3600 ), 3600 ) / 60 )//FormatVAR H =IF ( HOURS > 1, FORMAT ( HOURS, "00" ),BLANK())RETURNH AVG TTA (Min) =//CALCULATIONSVAR Dur = AVERAGE ( Table[TTA (Sec)] )//Separate TimeVAR DAYS = IF ( Dur >= 1, INT ( Dur / 86400 ), BLANK () )VAR HOURS = IF ( Dur >= 1, INT ( MOD ( Dur - ( Days * 86400 ), 86400 ) / 3600 ), BLANK () )VAR MINUTES = INT ( MOD ( Dur - ( Hours * 3600 ), 3600 ) / 60 )//FormatVAR M =FORMAT ( MINUTES, "00" )RETURNM

After creating the 3 measures I created a Small table to display the results and the filters/slicers for different months are now working to update the average:

Examples:  Time to Activate = Time taken from ticket creation to the time someone begins working a ticket.

Time to Close = Time taken from ticket creation to the time a ticket is closed.

3 REPLIES 3 Community Support Team

## Re: Need Help with Time calculation and filters

Hi @Wkbdrguy ,

AFAIK, date/time values not able to apply aggregation calculations.
I'd like to suggest you to take a look at following blog to conserve them as time durations for calculate:

Aggregating Duration/Time

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

For learning resources/Release notes, please visit: | |
Highlighted
Wkbdrguy Frequent Visitor

## Re: Need Help with Time calculation and filters

Figured it out. See other post.
Wkbdrguy Frequent Visitor

## Re: Need Help with Time calculation and filters

Solved: I created 3 separate measures:

 AVG TTA (Days)  =//CALCULATIONSVAR Dur = AVERAGE ( Table[TTA (Sec)] )//Separate TimeVAR DAYS = IF ( Dur >= 1, INT ( Dur / 86400 ), BLANK () )VAR HOURS = IF ( Dur >= 1, INT ( MOD ( Dur - ( Days * 86400 ), 86400 ) / 3600 ), BLANK () )VAR MINUTES = INT ( MOD ( Dur - ( Hours * 3600 ), 3600 ) / 60 )//FormatVAR D =IF ( DAYS > 1, FORMAT ( DAYS, "00" ), BLANK () )RETURND AVG TTA (Hours) =//CALCULATIONSVAR Dur = AVERAGE ( Table[TTA (Sec)] )//Separate TimeVAR DAYS = IF ( Dur >= 1, INT ( Dur / 86400 ), BLANK () )VAR HOURS = IF ( Dur >= 1, INT ( MOD ( Dur - ( Days * 86400 ), 86400 ) / 3600 ), BLANK () )VAR MINUTES = INT ( MOD ( Dur - ( Hours * 3600 ), 3600 ) / 60 )//FormatVAR H =IF ( HOURS > 1, FORMAT ( HOURS, "00" ),BLANK())RETURNH AVG TTA (Min) =//CALCULATIONSVAR Dur = AVERAGE ( Table[TTA (Sec)] )//Separate TimeVAR DAYS = IF ( Dur >= 1, INT ( Dur / 86400 ), BLANK () )VAR HOURS = IF ( Dur >= 1, INT ( MOD ( Dur - ( Days * 86400 ), 86400 ) / 3600 ), BLANK () )VAR MINUTES = INT ( MOD ( Dur - ( Hours * 3600 ), 3600 ) / 60 )//FormatVAR M =FORMAT ( MINUTES, "00" )RETURNM

After creating the 3 measures I created a Small table to display the results and the filters/slicers for different months are now working to update the average:

Examples:  Time to Activate = Time taken from ticket creation to the time someone begins working a ticket.

Time to Close = Time taken from ticket creation to the time a ticket is closed.

Announcements #### Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future. Learn the answers to some of the questions asked during the Amanda Triple A event. #### October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.  Top Kudoed Authors
Users Online
Currently online: 177 members 1,794 guests
Recent signins:
• nhoward • KatiaWilliams • rh90210 • sabd • quichejackson • benjamin_sasin • Momotaro • jacobson00 • tachen • smalis • richtolley • EricJ • erichaynie • colin_sutton 