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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
drstrong
Frequent Visitor

Measure to calculate average ticket duration

I have 2 tables, one with ticket details one with dates. I need to calculate the average age of tickets per month. My reports are filtered on the date table month column.

I have 3 inactive relationships with the date table to calculate open,closed, target closed but cannot seem to figure the average age out at all. 

My below attempts to even calculate the tickets closed same month as opened produces wrong totals.

 

CALCULATE(DISTINCTCOUNT(Bugs[issuenum_id]),

FILTER(ticket,MONTH(ticket[resolutiondate]) = MONTH(ticket[created]) &&YEAR(ticket[resolutiondate]) = YEAR(ticket[created])),

USERELATIONSHIP('date'[Date],ticket[resolutiondate]))

 

/*CALCULATE(COUNTROWS('ticket'),

FILTER(ticket,

MONTH(ticket[resolutiondate]) = MONTH(ticket[created])),

USERELATIONSHIP(ticket[resolutiondate],'date'[Date]))

*/

 

/*

CALCULATE(DISTINCTCOUNT(ticket[issuenum_id]),

MONTH(ticket[resolutiondate]) = MONTH(ticket[created]),

USERELATIONSHIP('date'[Date],ticket[resolutiondate]))*/

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @drstrong

 

If you want to calculate the average age of tickets per month, here is the method I provided:

 

Here's some dummy data

 

“ticket”

vnuocmsft_0-1710901919490.png

 

First, create a calculated column that counts the number of days the ticket lasted.

 

days = DATEDIFF('ticket'[created], 'ticket'[closed], DAY)

 

 

vnuocmsft_1-1710902078211.png

 

Create a measure to calculate the average age of tickets per month.

 

average age of tickets = 
var _month = MONTH(SELECTEDVALUE(ticket[created]))
var _day = DATEDIFF(SELECTEDVALUE('ticket'[created]), SELECTEDVALUE('ticket'[closed]), DAY)
return 
CALCULATE(
    SUM('ticket'[days]), 
    FILTER(ALL('ticket'), MONTH('ticket'[created]) = _month)
) 
/ 
CALCULATE(
    COUNTROWS('ticket'), 
    FILTER(ALL('ticket'), MONTH('ticket'[created]) = _month)
)

 

 

Here is the result.

 

vnuocmsft_2-1710902194049.png

 

If you're still having problems, provide some dummy data and the desired outcome. It is best presented in the form of a table.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @drstrong

 

If you want to calculate the average age of tickets per month, here is the method I provided:

 

Here's some dummy data

 

“ticket”

vnuocmsft_0-1710901919490.png

 

First, create a calculated column that counts the number of days the ticket lasted.

 

days = DATEDIFF('ticket'[created], 'ticket'[closed], DAY)

 

 

vnuocmsft_1-1710902078211.png

 

Create a measure to calculate the average age of tickets per month.

 

average age of tickets = 
var _month = MONTH(SELECTEDVALUE(ticket[created]))
var _day = DATEDIFF(SELECTEDVALUE('ticket'[created]), SELECTEDVALUE('ticket'[closed]), DAY)
return 
CALCULATE(
    SUM('ticket'[days]), 
    FILTER(ALL('ticket'), MONTH('ticket'[created]) = _month)
) 
/ 
CALCULATE(
    COUNTROWS('ticket'), 
    FILTER(ALL('ticket'), MONTH('ticket'[created]) = _month)
)

 

 

Here is the result.

 

vnuocmsft_2-1710902194049.png

 

If you're still having problems, provide some dummy data and the desired outcome. It is best presented in the form of a table.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.