Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Wkbdrguy
Employee
Employee

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

Solved: I created 3 separate measures: 

 

AVG TTA (Days)  =

//CALCULATIONS

VAR Dur = AVERAGE ( Table[TTA (Sec)] )

//Separate Time

VAR 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 )

//Format

VAR D =

IF ( DAYS > 1, FORMAT ( DAYS, "00" ), BLANK () )

RETURN

D

AVG TTA (Hours) =

//CALCULATIONS

VAR Dur = AVERAGE ( Table[TTA (Sec)] )

//Separate Time

VAR 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 )

//Format

VAR H =

IF ( HOURS > 1, FORMAT ( HOURS, "00" ),BLANK())

RETURN

H

AVG TTA (Min) =

//CALCULATIONS

VAR Dur = AVERAGE ( Table[TTA (Sec)] )

//Separate Time

VAR 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 )

//Format

VAR M =

FORMAT ( MINUTES, "00" )

RETURN

M

 

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:

Capture.JPG

 

 

 

 

Capture1.JPG

 

 

 

 

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.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

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
If this post helps, please consider accept as solution to help other members find it more quickly.

Figured it out. See other post.

Solved: I created 3 separate measures: 

 

AVG TTA (Days)  =

//CALCULATIONS

VAR Dur = AVERAGE ( Table[TTA (Sec)] )

//Separate Time

VAR 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 )

//Format

VAR D =

IF ( DAYS > 1, FORMAT ( DAYS, "00" ), BLANK () )

RETURN

D

AVG TTA (Hours) =

//CALCULATIONS

VAR Dur = AVERAGE ( Table[TTA (Sec)] )

//Separate Time

VAR 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 )

//Format

VAR H =

IF ( HOURS > 1, FORMAT ( HOURS, "00" ),BLANK())

RETURN

H

AVG TTA (Min) =

//CALCULATIONS

VAR Dur = AVERAGE ( Table[TTA (Sec)] )

//Separate Time

VAR 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 )

//Format

VAR M =

FORMAT ( MINUTES, "00" )

RETURN

M

 

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:

Capture.JPG

 

 

 

 

Capture1.JPG

 

 

 

 

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.