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
Robert1981
Helper II
Helper II

Calculate difference between dates in table and date in measure

In the picture below I am displaying open tickets for our tracker.

One calculation I don't know how to do is:

How do I calculate the average days the open tickets have been open (Ave_days_Open = ???).

I have a measure [Date_Selected] that is populated based on the Chiclet slicers for Year and Month.
For all tickets that were open at the end of the selected Month/Year, I need to calculate the average open days.

In the table: 'Tickets' I have columns for: 'Tickets'[Notification_Date] and 'Tickets'[Resolution_Date]. 
All tickets appear more than once in the table, because they can have multiple techs assigned, apply to multiple countries, etc.

I can't figure out how to calculate the difference between the 'Tickets'[Notification_Date] of the tickets and the [Date_Selected], where:
'Tickets'[Notification_Date]<[Date_Selected] AND OR('Tickets'[Resolution_Date]>[Date_Selected], Isblank('Tickets'[Resolution_Date]) for distinct [Ticket_Id] in the selected

 

Robert1981_0-1647099170593.png

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

I think the below should work

average open time =
var chosenDate = [Date_Selected]
return
AVERAGEX(
CALCULATETABLE(
SUMMARIZE( Tickets, Tickets[Id], Tickets[NotificationDate] ),
Tickets[Resolutiondate] > chosenDate || ISBLANK( Tickets[Resolutiondate] )
),
DATEDIFF( Tickets[NotificationDate], chosenDate, DAY)
)

View solution in original post

8 REPLIES 8
johnt75
Super User
Super User

I think the below should work

average open time =
var chosenDate = [Date_Selected]
return
AVERAGEX(
CALCULATETABLE(
SUMMARIZE( Tickets, Tickets[Id], Tickets[NotificationDate] ),
Tickets[Resolutiondate] > chosenDate || ISBLANK( Tickets[Resolutiondate] )
),
DATEDIFF( Tickets[NotificationDate], chosenDate, DAY)
)

It worked perfectly. Thank you!

thank you,
although, I don't think this formula takes into consideration the fact that the same [ID] will appear multiple times in the report (once for every consultant assigned, or country impacted). This would skew the average, no?

That's what the SUMMARIZE does, it reduces the multiple entries to 1 entry per ticket ID

littlemojopuppy
Community Champion
Community Champion

Hi @Robert1981 this wouldn't be too hard except you've got tickets appearing multiple times in the data.  Can you share a sample to play with?

Not sure how I can share the report. It is linked to SharePoint and there is confidential company information in there

@Robert1981 can you mock up some sample data without anything confidential into another pbix?  Save it to OneDrive, Google Drive, Dropbox, etc. and provide a link for download.

Here is the mocked up report. Thqank you for your help Link here 

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.