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
thomasreick
Resolver I
Resolver I

Calculate a total count of TicketId within Opening and Close-Date in a selected period

Hello there,

I am using one dim_date Table via DAX-CALCULATE to relate to several date columns in my fact_Table to find numbers of opened, solved and closed tickets. The task is to find the number of tickets opened AND closed within a period selected with a slicer.

 

In the fact_Table are records with an opening-date prior the selected period where only a closing date is available.

 

Thus made me think of "how to get the count of tickets handled start-to-end from this period"?

Appreciating your input.

thanks in advance

Thomas

 

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @thomasreick ,

 

I have created the following example data. 

 

vkkfmsft_0-1652950184814.png

 

If you want to calculate the ticketid opened and closed during the selected period, please create the following relationships and measure.

 

vkkfmsft_1-1652950209501.png

Open And Closed = 
CALCULATE (
    DISTINCTCOUNT ( fact_Table[TicketId] ),
    USERELATIONSHIP ( dim_date[Date], fact_Table[DateClosed] )
)

vkkfmsft_2-1652950240235.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
v-kkf-msft
Community Support
Community Support

Hi @thomasreick ,

 

I have created the following example data. 

 

vkkfmsft_0-1652950184814.png

 

If you want to calculate the ticketid opened and closed during the selected period, please create the following relationships and measure.

 

vkkfmsft_1-1652950209501.png

Open And Closed = 
CALCULATE (
    DISTINCTCOUNT ( fact_Table[TicketId] ),
    USERELATIONSHIP ( dim_date[Date], fact_Table[DateClosed] )
)

vkkfmsft_2-1652950240235.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

thomasreick
Resolver I
Resolver I

One more thing...., I hope this may help to get my point.

 

The desired measure should represent an output, which can be achieved using an SQL-Statement like this and shows only the COUNT() aof a subset of all the tickets:


select count(TicketId)
from tblTickets
where (DateOpened between '01.04.2022' and '30.04.2022')
and (DateSolved between '01.04.2022' and '30.04.2022')
and (DateClosed between '01.04.2022' and '30.04.2022')

but..., the time period is taken from a dimDate (Slicer with Year and Month selected).

 

Can you help?

Thomas

thomasreick
Resolver I
Resolver I

Hello ribisht17,

cannot upload data, not allowed to do so. But the task itself should be pretty self explaining.

The runtime of tickes (ideally: opening => solving => close) might overlap into the next month, so the Slicer set to e.g. 2022 May cannot catch the complete "lifetime" of the ticket.

The question is: 

How do I calculate in a DAX Measure how many tickets are [opened (solved) and closed] within May 2022.

 

I have created 2 measures, each one uses its own relation to dim_Date (my Calendar-Table) whilst the first relation is established 1:n between dim_Date][Datum] and facts.[OpeningDate].

 

#SolvedTickets=

CALCULATE(

COUNT(facts.[pkFact]),(dim_Date.Datum, facts.[SolvedDate])

)

#ClosedTickets=

CALCULATE(

COUNT(facts.[pkFact]),USERELATIONSHIP (dim_Date.Datum, facts.[ClosedDate])

)

 

Can you handle this explanation to get the point?

rgds

Thomas

 

ribisht17
Super User
Super User

@thomasreick 

 

Please paste some data here

 

Regards,

Ritesh

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.