Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Create measure to calculate whether ClosedDate and CreatedDate are in same period?

Hi, hopefully someone can help with this.

I have a dataset that looks at tickets created and closed on a service desk. Both created date and closed date are joined to a calendar table.

 

What I want to be able to do is create a measure which counts number of tickets created AND closed in the selected period. For example, a user selects June 2018 and it will count all tickets that were created in june 2019 and solved in June 2019. Any without a solve date or a solve date higher than june 2019 won't show up, and neither will tickets created before or after this period. If the user then selects the whole of 2018 - it will apply this same logic to the entire year.


 

Does this make sense? Hopefully someone can help

Thanks!

1 ACCEPTED SOLUTION
TeigeGao
Solution Sage
Solution Sage

HI @Anonymous ,

Assum that we have a table like below:

PBIDesktop_Rl1f8uYmym.png

Then first we need to create a calendar table for slicer like below without relationship between above table:

Table = CALENDAR(DATE(2018,01,01),DATE(2019,12,31))

After that, we can create a measure using the following DAX query:

count_ticket =
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER (
        ALL ( Table1 ),
        Table1[createddate] >= MIN ( 'Table'[Date] )
            && Table1[createddate] <= MAX ( 'Table'[Date] )
            && Table1[closeddate] >= MIN ( 'Table'[Date] )
            && Table1[closeddate] <= MAX ( 'Table'[Date] )
    )
)

The drag the measure to a card to display and drag the calendar to a slicer, the result will like below:

aDrGtKEGUD.gif

Best Regards,

Teige

View solution in original post

1 REPLY 1
TeigeGao
Solution Sage
Solution Sage

HI @Anonymous ,

Assum that we have a table like below:

PBIDesktop_Rl1f8uYmym.png

Then first we need to create a calendar table for slicer like below without relationship between above table:

Table = CALENDAR(DATE(2018,01,01),DATE(2019,12,31))

After that, we can create a measure using the following DAX query:

count_ticket =
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER (
        ALL ( Table1 ),
        Table1[createddate] >= MIN ( 'Table'[Date] )
            && Table1[createddate] <= MAX ( 'Table'[Date] )
            && Table1[closeddate] >= MIN ( 'Table'[Date] )
            && Table1[closeddate] <= MAX ( 'Table'[Date] )
    )
)

The drag the measure to a card to display and drag the calendar to a slicer, the result will like below:

aDrGtKEGUD.gif

Best Regards,

Teige

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.