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
Anonymous
Not applicable

Calculate total open tickets at specific dates

Info: Using Direct Query, Star schema, fact table with one row per status-change for any ticketID

 

Hello! 

I'm having a very hard time calculating the number of "current" tickets at a specific date (dates picked using date slicer). 

 

I have a fact table containing the following "ticketID", "regID", "regDate", "ticketStatus"

One ticketID can have multiple rows in the fact-table, depending on how often it changes status. Status can be "open", "in process", "paused" or "closed". 

 

I need to be able to look at any date and get a measure showing how many current tickets (status = "open" or "in process") were in the system at that time. How can this be achieved in DAX? (I've seen some calculated colums-solutions, but Direct Query has 1M limit). 

RegID is allways larger based on when it is recieved in the system, so its the optimal to sort out the newest row for any tickedID (regDate is no good as multiple status changes can be done at the same day). 

 

In other words: I'm looking for the count of [ticketStatus] = ("open" or "in progress") at specific date based on MAX [regID] for each [ticketID]

 

Is this possible using DAX in a measure? 

If not, could it be done using any tricks in the query editor?

 

Here is an example. Lets say I'm looking for current tickets at date 15. jan. 2020 the number should be: 2 

 

ticketIDregIDregDateticketStatus
33018140103.jan.2020Open
330181403

06.jan.2020

In Progress
33018140613.jan.2020Closed
33028140206.jan.2020Open
33038140409.jan.2020Open
33038140512.jan.2020In Progress

 

 

 

Best.

PJ

 

6 REPLIES 6
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

Kindly refer to the similar threads:

https://community.powerbi.com/t5/Desktop/Calculating-Open-Tickets-at-Specific-Hour/m-p/277385 

https://community.powerbi.com/t5/Desktop/calculate-open-tickets-by-date/m-p/207196 

https://community.powerbi.com/t5/Desktop/Calculate-Number-of-Tickets-Open-at-the-End-of-the-Month/m-p/259410 

 

If you can't manage it, kindly upload your dummy pbix with the expected results disclosed would be much appreciated.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

Thanks for the suggested forum posts. 
My dataset differs from most of them in that it has one row per status and no "open" "close" columns in the table it self. 

 

However, the first forum-post @v-diye-msft liked has a very similar structure as mine and will work with some slight adjustments (I hope). 

 

Screen clip: 

data.png

 

The only difference from my dataset is that one ticket may have two different "open"-status over the course of its "life" and simply adding a -1 when closed is not sufficient. More specifically, a ticket can have rows displaying status as "Open" and "In Progress". Other tickets may go from "Open" to "Close", without passing through "In Progress". Also some tickets only have "In Progress" then "Close". Some might even only have "Close" without any prior "Open" or "In Progres" (in such case it shouldent be counted at all"). 

 

Suggestions? 

Hi @Anonymous 

 

what's your expecting for the "In progress" tickets? kindly upload your dummy pbix and disclose the expecting results.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

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

 

TicketIDStatusFrom DateTo Date
1Waiting1.apr.20201.apr.2020
2Waiting1.apr.20203.apr.2020
1In Progress1.apr.20203.apr.2020
3Waiting1.apr.2020 
4Waiting2.apr.20203.apr.2020
5Waiting2.apr.20205.apr.2020
6Waiting2.apr.20205.apr.2020
7Waiting2.apr.20206.apr.2020
8Waiting2.apr.20206.apr.2020
1Closed3.apr.20204.apr.2020
2In Progress3.apr.2020 
4In Progress3.apr.20208.apr.2020
5In Progress5.apr.20205.apr.2020
5Closed5.apr.2020 
6In Progress5.apr.2020 
7In Progress6.apr.20206.apr.2020
7Closed6.apr.2020 
8Closed6.apr.2020 
4Closed8.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: 

TicketIDStatusFrom DateTo Date
1Waiting1.apr.20201.apr.2020
2Waiting1.apr.20203.apr.2020
1In Progress1.apr.20203.apr.2020
3Waiting1.apr.2020 
4Waiting2.apr.20203.apr.2020
5Waiting2.apr.20205.apr.2020
6Waiting2.apr.20205.apr.2020
7Waiting2.apr.20206.apr.2020
8Waiting2.apr.20206.apr.2020
1Closed3.apr.20204.apr.2020
2In Progress3.apr.2020 
4In Progress3.apr.20208.apr.2020
5In Progress5.apr.20205.apr.2020
5Closed5.apr.2020 
6In Progress5.apr.2020 
7In Progress6.apr.20206.apr.2020
7Closed6.apr.2020 
8Closed6.apr.2020 
4Closed8.apr.2020 

 

2. Only count latest record for each TicketID

TicketIDStatusFrom DateTo Date
1Waiting1.apr.20201.apr.2020
2Waiting1.apr.20203.apr.2020
1In Progress1.apr.20203.apr.2020
3Waiting1.apr.2020 
4Waitinged2.apr.20203.apr.2020
5Waiting2.apr.20205.apr.2020
6Waiting2.apr.20205.apr.2020
7Waiting2.apr.20206.apr.2020
8Waiting2.apr.20206.apr.2020
1Closed3.apr.20204.apr.2020
2In Progress3.apr.2020 
4In Progress3.apr.2020

8.apr.2020

5In Progress5.apr.20205.apr.2020
5Closed5.apr.2020 
6In Progress5.apr.2020 

 

Final step: Only count those rows with To Date = null OR date later than filtered From Date

 

TicketIDStatusFrom DateTo Date
3Waiting1.apr.2020 
5Waiting2.apr.20205.apr.2020
6Waiting2.apr.20205.apr.2020
7Waiting2.apr.20206.apr.2020
8Waiting2.apr.20206.apr.2020
1Closed3.apr.20204.apr.2020
2In Progress3.apr.2020 
4In Progress3.apr.2020

8.apr.2020

5Closed5.apr.2020 
6In Progress5.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

Greg_Deckler
Super User
Super User

Maybe try: https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/td-p/409364


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.