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.
Link to post:
(Cumulative difference between count of two dates)
by AlfredR
<p>I have something that I haven't been able to solve trying to get information from a ticketing system. I have a table with two date fields, opendate and close date.<br />I have made two measures to calculate the count of dates for each field so that I can know based on that count, in a period of time how many tickets where opened and how many where closed. Here is an example of the data:</p><table><tbody><tr><td><p><strong>OpenDate</strong></p></td><td><p><strong>CloseDate</strong></p></td></tr><tr><td><p>10/07/2019</p></td><td><p>11/07/2019</p></td></tr><tr><td><p>10/07/2019</p></td><td><p> </p></td></tr><tr><td><p>11/07/2019</p></td><td><p>11/07/2019</p></td></tr><tr><td><p>11/07/2019</p></td><td><p>12/07/2019</p></td></tr><tr><td><p>13/07/2019</p></td><td><p>12/07/2019</p></td></tr><tr><td><p>13/07/2019</p></td><td><p>13/07/2019</p></td></tr><tr><td><p>13/07/2019</p></td><td><p>19/07/2019</p></td></tr><tr><td><p>14/07/2019</p></td><td><p>13/07/2019</p></td></tr><tr><td><p>14/07/2019</p></td><td><p>13/07/2019</p></td></tr><tr><td><p>14/07/2019</p></td><td><p>14/07/2019</p></td></tr><tr><td><p>15/07/2019</p></td><td><p>14/07/2019</p></td></tr><tr><td><p>15/07/2019</p></td><td><p> </p></td></tr><tr><td><p>15/07/2019</p></td><td><p>15/07/2019</p></td></tr><tr><td><p>15/07/2019</p></td><td><p>15/07/2019</p></td></tr><tr><td><p>16/07/2019</p></td><td><p>15/07/2019</p></td></tr><tr><td><p>16/07/2019</p></td><td><p>15/07/2019</p></td></tr><tr><td><p>16/07/2019</p></td><td><p>16/07/2019</p></td></tr><tr><td><p>16/07/2019</p></td><td><p> </p></td></tr><tr><td><p>17/07/2019</p></td><td><p>17/07/2019</p></td></tr><tr><td><p>17/07/2019</p></td><td><p>17/07/2019</p></td></tr><tr><td><p>18/07/2019</p></td><td><p>17/07/2019</p></td></tr><tr><td><p>19/07/2019</p></td><td><p>18/07/2019</p></td></tr><tr><td><p>19/07/2019</p></td><td><p> </p></td></tr><tr><td><p>19/07/2019</p></td><td><p> </p></td></tr><tr><td><p>19/07/2019</p></td><td><p>19/07/2019</p></td></tr></tbody></table><p><br />My measures are:<br /><br />Tickets Opended = COUNTX(tickets,tickets[OpenDate])<br />Tickets Closed = COUNTX(tickets,tickets[CloseDate])<br /><br />I calculate by date the tickets not solved in a period by substracting those two measutres. Now what I'm trying to acomplish now is keep track of the sum of difference of those counts over time. Let's say that on day one I had one ticket not closed, and day two I had another ticket not closed, the pending tickets should be two, not one. And if on day three I have 5 tickets opened and 3 closed that two not closed should sum with the two remaining from other periods so I have 4 tickets pending. If on a fourth day I have 3 tickets opened and 4 closed then the total pending should be 3 because I closed an older ticket.<br /><br />I haven't been able to figure out how to do that. I'm visualizing this data in a column graph where the values are those measures and the axis is the date of the ticket creation.<br /><br />Any help would be appreciated.</p>
This message has 0 replies
Solved! Go to Solution.
Hi @AlfredR ,
When I open your pbix it prompts that it's created in older version, and not sure whether you could open the pbix which made changes in latest version. try below measure:
Measure = CALCULATE(SUMX(Tickets,[Pending]),FILTER(ALL('calendar'),[Date]<=MAX([Date])),VALUES('calendar'[Date].[MonthNo]))
And find the file here:
Hi @AlfredR ,
Please check this :
Note that I convert the date/time to date in query editor to make sure counts based on day rather than time. and set the month as cut.
Best regards,
Dina Ye
Here is my file with what I'm at right now based on your help.
Opened = COUNT(Tickets[date])
Closed = CALCULATE( COUNT(Tickets[solvedate]), FILTER(Tickets,Tickets[solvedate] <= MAX('calendar'[Date])) )
Pending = [Opened] - [Closed]
What I'm missing is making the pending measure cummulative right now I only have it month by month.
Hi @AlfredR ,
When I open your pbix it prompts that it's created in older version, and not sure whether you could open the pbix which made changes in latest version. try below measure:
Measure = CALCULATE(SUMX(Tickets,[Pending]),FILTER(ALL('calendar'),[Date]<=MAX([Date])),VALUES('calendar'[Date].[MonthNo]))
And find the file here:
Hi @AlfredR ,
If my above post helps, could you please consider Accept it as the solution to help the other members find it more quickly. thanks!
Best regards,
Dina Ye
Hi @AlfredR ,
Please correct me if I go wrong:
Based on your data, you'd like to calculate:
On 10/7/2019, open 2, closed 0, so result should be 2.
On 11/7/2019, Open 2, closed 2, so result should still 2.
On 12/7/2019, Open 0, closed 1, so result should be 1.
On 13/07/2019, Open 3, closed 3, so result should be still 1.
......
if so, please follow below steps:
1.Add a new calculated table and manage the relationship :
Table 2 = CALENDAR(DATE(2019,7,1),DATE(2019,7,20))
OpenCounts = CALCULATE(COUNTROWS('Table')) CloseCounts = IF(MAX('Table'[CloseDate])=BLANK(),BLANK(),CALCULATE(COUNTROWS('Table'),USERELATIONSHIP('Table'[CloseDate],'Table 2'[Date]))) LeftcountsPerday = [OpenCounts]-[CloseCounts]then the final counts is the cumuletive sum of leftcountsPerday:
FinalCounts = SUMX(FILTER(ALL('Table 2'),[Date]<=MAX('Table 2'[Date])),[LeftcountsPerday])Results shown as below:
Best regards,
Dina Ye
Hi @AlfredR ,
If my above post helps, could you please consider Accept it as the solution to help the other members find it more quickly. thanks!
Best regards,
Dina Ye
Hello, thanks for the response, I'm trying it out now that I have a jump in month as I'll actually use a montly cut for tickets. I'll let you know how it goes. I did have a measure that worked but it only gave me the current month not cumulative:
First I calculated the Opened tickets:
OpenTickets = COUNT(tickets[Ticket Date])
CloseTickets = COUNT(tickets[solvedate])
PendingTickets = CALCULATE(([OpenTickets] - [ClosedTickets]), FILTER(ALLSELECTED(tickets[Ticket Date]), tickets[Ticket Date] <= MAX(tickets[Ticket Date])))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
76 | |
74 | |
49 |
User | Count |
---|---|
145 | |
108 | |
107 | |
89 | |
61 |