Forum Discussion
Tickets over time
Hi everyone,
I'm trying to solve the following issue. I need to get list of tickets open over time with multiple rows for the same ticket id. I've been through and read many posts around this. However they only ever talk about having one entry per row. That I can count easily
I have a table which stores ticket and has a from & to dates for the days it stayes in that team. The ticket may move between several different teams. Before it is closed. Also, some tickets will have a from date but yet to be completed so will have no To date. See the table example below. or attached Pbix.
If I had only row per REF that would be fine, but unfortunately, I can have multiple. Also, a ticket can be closed (Have To date) and then be reopened. Which also means it might have up to 5 days in between where it was resolved. (This can happen multiple times). Table is updated nightly so Id never see a ticket be with two teams on the same day. If I report over a month then a number of tickets would get counted more than once as they appear multiple times.
I'd also like to be able break this down by team. As well as to link this table via ID field back to a fact table so that we can look at ticket in more detail(Which I've already done.) I Don't have a date table for the From\To (Though I do on other more import dates in other tables)
I'm assuming I need to create some virtual table of the dates chosen with those tickets which are applicable and then do a distinct count on the ref number.
(This is not our full dataset to big to post but this is type of table we will have. So should help)
Mock up Pbix
Reg | From | To | Team | Closed |
1 | 1/1/2025 | 3/1/2025 | Team A | No |
1 | 4/1/2025 | 4/1/2025 | Team B | No |
1 | 5/1/2025 | 8/1/2025 | Team A | Yes |
2 | 1/1/2025 | 2/1/2025 | Central Team | Yes |
3 | 2/1/2025 | 5/1/2025 | Team A | No |
3 | 6/1/2025 |
| Admin Team | No |
Thanks for looking and hopefully someone can help where I have failed
3 Replies
- rajendraongole1Super User
Hi locka - you're on the right track! Since tickets can have multiple entries and may reopen.
I hope you already have a date table, if not please create it using calcualted table.
another table
Tickets_Expanded =
VAR TicketDates =
SELECTCOLUMNS (
FILTER (
CROSSJOIN ( 'DateTable', 'Tickets' ),
'DateTable'[Date] >= 'Tickets'[From] &&
('Tickets'[To] = BLANK() || 'DateTable'[Date] <= 'Tickets'[To])
),
"Date", 'DateTable'[Date],
"TicketID", 'Tickets'[Reg],
"Team", 'Tickets'[Team]
)
RETURN
TicketDatescreate a measure to count the tickets
Active Tickets =
CALCULATE (
DISTINCTCOUNT ( Tickets_Expanded[TicketID] ),
CROSSFILTER ( 'DateTable'[Date], Tickets_Expanded[Date], BOTH )
)For distinct tickets create another measure
Active Tickets by Team =
CALCULATE (
DISTINCTCOUNT ( Tickets_Expanded[TicketID] ),
CROSSFILTER ( 'DateTable'[Date], Tickets_Expanded[Date], BOTH ),
VALUES ( Tickets_Expanded[Team] )
)Hope this helps.
- govind_021Super User
Hey locka
Please try follwoing code , it may work
Open Tickets =
VAR SelectedDates =
FILTER(
ADDCOLUMNS(
ALL('Tickets'),
"IsOpen",
'Tickets'[From] <= MAX('DateTable'[Date]) &&
(ISBLANK('Tickets'[To]) || 'Tickets'[To] >= MIN('DateTable'[Date]))
),
[IsOpen] = TRUE
)
RETURN
DISTINCT(SELECTCOLUMNS(SelectedDates, "TicketID", 'Tickets'[Reg]))
Regards
Regards
Govind Sapkade ( Data Analyst , Power BI PL 300 Certified , MS Fabric Enthusiast )
Linkdin : www.linkedin.com/in/govind-sapkade-845104225
Youtube : http://www.youtube.com/@govind_dataanalyst - lockaResolver I
Good morning everyone. It's been a while since my orginal post my requirments have changed a little. Although for my inital report I was able to fix it with dax measure similar to below. I now need to be more procises as tickets can be past between multiple people and or teams across the same peroid including same day. I'm still looking to do a distinct count number of ticket id over a selected period.
This is to be used in a thin report which links to a dataset. (They are sepreate files.) I need this to caculate this as measure rather than a caculated table or power query etc. I also want to make sure it can work with a drill through with list of id to allow viewer further insite.
My main issue is there there they can be multiple entries for the same ID over the period, either on the same day or different days. Viewer of the report can filter by a date period or the agent id or team id and bring in those tickets which match. It's basically a tickets over time.
While I already have DAX code which calculates a distinct count of tickets. When filtered by agent or team the distinct count of id and then shown it in a matrix. The matrix is split by person which means tickets get counted more than once currently.
Ideally Id like to count max date time of the period per id so it would only count it once by who ever last had the ticket. That way I can can get an accurate breakdown of how many tickets an agent or team had in period selected. So that we can go back in the past and see how many tickets a team or agent had.
VAR MaxDate = MAX ( '@DIM_Date'[Date] ) // Newest date in the date table. VAR MinDate = MIN ( '@DIM_Date'[Date] ) // Earlist date in the date table. VAR Result = CALCULATE( DISTINCTCOUNT(FACT_FaultAssignmentHistory[Faultid]), FACT_FaultAssignmentHistory[FromDate] <= MaxDate // Include tickets upto the end of the period. , ( FACT_FaultAssignmentHistory[ToDate] >= MinDate || ISBLANK ( FACT_FaultAssignmentHistory[ToDate] ) //Include tickets that are already open or create in the period. ), ( FACT_Faults[ResolvedDate] >= MinDate || FACT_Faults[BeenResolved] = 0 //Includes those tickets which have a resolved date within period or have yet to be resolved. ), FACT_FaultAssignmentHistory[AssignedAgentID] IN VALUES('@DIM_Agent'[AgentID]) && FACT_FaultAssignmentHistory[AgentTeam] IN VALUES('@DIM_Teams'[AgentTeam]) ) RETURN Result
Here is a sample of data below of entry every time a ticket I also have date field as well as date time ones. This table is linked to fact table via a relationship a 1 to many. Every time a ticket moved to another person or team. It is recorded in the fact table below. A separate table has list of all the tickets and other information such as has the ticket been closed or not . I have disconnected datetable , agent and teams tables due to the fact they need to refer to multiple tables and or the same table multiple times for different reasons.
Table Name: Fact_FaultsAssignmentHistoryid AgentID AgentTeam FromDateTime ToDateTime 199914 184 2 08/08/2025 17:19 11/08/2025 12:45 239402 1 2 11/08/2025 10:32 11/08/2025 10:59 243191 143 4 05/08/2025 11:50 11/08/2025 10:19 243516 143 4 05/08/2025 11:53 11/08/2025 10:20 244259 153 2 24/07/2025 14:22 11/08/2025 10:54 245023 174 8 08/08/2025 16:31 11/08/2025 15:20 246629 177 2 08/08/2025 16:38 11/08/2025 10:13 247246 175 2 01/08/2025 16:34 11/08/2025 07:45 247492 40 2 06/08/2025 08:06 11/08/2025 09:17 247937 186 2 30/07/2025 08:16 11/08/2025 09:22 249169 1 2 11/08/2025 10:54 11/08/2025 14:10 249169 22 1 06/08/2025 15:13 11/08/2025 10:54 249273 38 6 08/08/2025 09:40 11/08/2025 08:16 249744 162 2 04/08/2025 09:09 11/08/2025 12:10 250200 162 2 04/08/2025 10:52 11/08/2025 09:30 250382 1 2 11/08/2025 12:06 11/08/2025 12:33 250382 161 2 04/08/2025 13:50 11/08/2025 12:06 250383 1 1 05/08/2025 16:06 11/08/2025 16:10 250502 1 2 11/08/2025 12:40 11/08/2025 13:03 250502 154 2 04/08/2025 16:13 11/08/2025 12:40 250521 125 2 08/08/2025 15:01 11/08/2025 10:03 250597 40 2 06/08/2025 08:06 11/08/2025 09:21 250872 40 2 06/08/2025 08:06 11/08/2025 09:18 250909 161 2 05/08/2025 11:33 11/08/2025 13:55 250964 1 2 10/08/2025 06:56 11/08/2025 08:53 251230 132 2 05/08/2025 16:42 11/08/2025 08:49 251274 1 4 11/08/2025 16:43 11/08/2025 16:50 251342 40 2 06/08/2025 10:21 11/08/2025 09:20 251361 124 3 07/08/2025 09:48 11/08/2025 08:44 251489 1 3 11/08/2025 11:45 11/08/2025 12:22 251489 127 3 11/08/2025 12:22 11/08/2025 12:28 251589 40 2 06/08/2025 11:54 11/08/2025 09:19