Forum Discussion
Calculate total open tickets at specific dates
Hi, again. Thanks for helping v-diye-msft & Greg_Deckler
Let me refrase the question. I've discovered that I can include a "to-date" column as well that I think can help solving this problem easier.
Unrelated to my first table in the topic-post, here are another example, highlighting the structure of the table I'm working on.
To avoid confusion I've changed status names a bit. In this example a ticket is open if Status = "Waiting" OR "In Progress".
My goal is to create a measure that outputs the number of open tickets at specified date set by a slicer. The slicer filters on From Date and should filter the fact table to only get the latest record for each TicketID. This can be obtained by filtering/only counting those rows having To Date = null OR "later than the filtered From Date" (meaning that i was open on that specific date).
| TicketID | Status | From Date | To Date |
| 1 | Waiting | 1.apr.2020 | 1.apr.2020 |
| 2 | Waiting | 1.apr.2020 | 3.apr.2020 |
| 1 | In Progress | 1.apr.2020 | 3.apr.2020 |
| 3 | Waiting | 1.apr.2020 | |
| 4 | Waiting | 2.apr.2020 | 3.apr.2020 |
| 5 | Waiting | 2.apr.2020 | 5.apr.2020 |
| 6 | Waiting | 2.apr.2020 | 5.apr.2020 |
| 7 | Waiting | 2.apr.2020 | 6.apr.2020 |
| 8 | Waiting | 2.apr.2020 | 6.apr.2020 |
| 1 | Closed | 3.apr.2020 | 4.apr.2020 |
| 2 | In Progress | 3.apr.2020 | |
| 4 | In Progress | 3.apr.2020 | 8.apr.2020 |
| 5 | In Progress | 5.apr.2020 | 5.apr.2020 |
| 5 | Closed | 5.apr.2020 | |
| 6 | In Progress | 5.apr.2020 | |
| 7 | In Progress | 6.apr.2020 | 6.apr.2020 |
| 7 | Closed | 6.apr.2020 | |
| 8 | Closed | 6.apr.2020 | |
| 4 | Closed | 8.apr.2020 |
So. Lets say I wanted to get all open tickets at From Date = 5.apr.2020
Step-by-step, the measure needs to go through these steps:
1. filter by From Date:
| TicketID | Status | From Date | To Date |
| 1 | Waiting | 1.apr.2020 | 1.apr.2020 |
| 2 | Waiting | 1.apr.2020 | 3.apr.2020 |
| 1 | In Progress | 1.apr.2020 | 3.apr.2020 |
| 3 | Waiting | 1.apr.2020 | |
| 4 | Waiting | 2.apr.2020 | 3.apr.2020 |
| 5 | Waiting | 2.apr.2020 | 5.apr.2020 |
| 6 | Waiting | 2.apr.2020 | 5.apr.2020 |
| 7 | Waiting | 2.apr.2020 | 6.apr.2020 |
| 8 | Waiting | 2.apr.2020 | 6.apr.2020 |
| 1 | Closed | 3.apr.2020 | 4.apr.2020 |
| 2 | In Progress | 3.apr.2020 | |
| 4 | In Progress | 3.apr.2020 | 8.apr.2020 |
| 5 | In Progress | 5.apr.2020 | 5.apr.2020 |
| 5 | Closed | 5.apr.2020 | |
| 6 | In Progress | 5.apr.2020 | |
| 7 | In Progress | 6.apr.2020 | 6.apr.2020 |
| 7 | Closed | 6.apr.2020 | |
| 8 | Closed | 6.apr.2020 | |
| 4 | Closed | 8.apr.2020 |
2. Only count latest record for each TicketID
| TicketID | Status | From Date | To Date |
| 1 | Waiting | 1.apr.2020 | 1.apr.2020 |
| 2 | Waiting | 1.apr.2020 | 3.apr.2020 |
| 1 | In Progress | 1.apr.2020 | 3.apr.2020 |
| 3 | Waiting | 1.apr.2020 | |
| 4 | Waitinged | 2.apr.2020 | 3.apr.2020 |
| 5 | Waiting | 2.apr.2020 | 5.apr.2020 |
| 6 | Waiting | 2.apr.2020 | 5.apr.2020 |
| 7 | Waiting | 2.apr.2020 | 6.apr.2020 |
| 8 | Waiting | 2.apr.2020 | 6.apr.2020 |
| 1 | Closed | 3.apr.2020 | 4.apr.2020 |
| 2 | In Progress | 3.apr.2020 | |
| 4 | In Progress | 3.apr.2020 | 8.apr.2020 |
| 5 | In Progress | 5.apr.2020 | 5.apr.2020 |
| 5 | Closed | 5.apr.2020 | |
| 6 | In Progress | 5.apr.2020 |
Final step: Only count those rows with To Date = null OR date later than filtered From Date
| TicketID | Status | From Date | To Date |
| 3 | Waiting | 1.apr.2020 | |
| 5 | Waiting | 2.apr.2020 | 5.apr.2020 |
| 6 | Waiting | 2.apr.2020 | 5.apr.2020 |
| 7 | Waiting | 2.apr.2020 | 6.apr.2020 |
| 8 | Waiting | 2.apr.2020 | 6.apr.2020 |
| 1 | Closed | 3.apr.2020 | 4.apr.2020 |
| 2 | In Progress | 3.apr.2020 | |
| 4 | In Progress | 3.apr.2020 | 8.apr.2020 |
| 5 | Closed | 5.apr.2020 | |
| 6 | In Progress | 5.apr.2020 |
Measure should display the number: 7 (as this was the number of tickets that was open (at the end of) 5.april.2020.
Hello, I have exactly the same set up and I am blocked on step 2, I couldn't adapt any post from the community so far.
Could you please help me sharing the DAX formula please?
"2. Only count latest record for each TicketID"
Thank you so much