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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

last 30 days count with condition

I'm searching for a calculation that involves conditional logic, depicting the number of tickets opened in the last 30 days.

 
Total Open Tickets days = CALCULATE(COUNT('Ticket_1673349003140 (1)'[Status]), 'Ticket_1673349003140 (1)'[Status] = "open"
, 'Ticket_1673349003140 (1)'[Created Time] >= NOW()-30 , 'Ticket_1673349003140 (1)'[Created Time] <= NOW())
 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.

vzhangti_0-1673401474852.png

Measure:

Total Open Tickets days = 
CALCULATE ( COUNT ( 'Ticket_1673349003140 (1)'[Status] ),
    FILTER ( ALL ( 'Ticket_1673349003140 (1)' ),
        [Status] = "open"
            && [Created Time] >= TODAY () - 30
            && [Created Time] <= TODAY ()
    )
)

vzhangti_1-1673401514392.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Assuming the created time column is a Date data type (and not a Date/Time data type), try this approach

  1. Create a Calendar Table
  2. Create a relationship (Many to One and Single) from the Created time column to the Date column of the Calendar Table
  3. Write these measures
    1.  Count = COUNT('Ticket_1673349003140 (1)'[Status])
    2. Count in last 30 days = calculate([count],datesbetween(Calendar[date],today()-30,today()))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.

vzhangti_0-1673401474852.png

Measure:

Total Open Tickets days = 
CALCULATE ( COUNT ( 'Ticket_1673349003140 (1)'[Status] ),
    FILTER ( ALL ( 'Ticket_1673349003140 (1)' ),
        [Status] = "open"
            && [Created Time] >= TODAY () - 30
            && [Created Time] <= TODAY ()
    )
)

vzhangti_1-1673401514392.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

Can you please provide sample data?

 

I think there is a general problem in your logic because typically ticket systems have one line-item per ticket. But requesting on status field would ignore tickets which have been opened duting last 30 days and closed within these days because they do not have status opened. So typically you would go on the creation time to identify an opened ticket.

 
Total Open Tickets days = 
CALCULATE(
   COUNT('Ticket_1673349003140 (1)'[Status]), 
   'Ticket_1673349003140 (1)'[Created Time] >= NOW()-30
)

 

Or is it different in your case? Can you please check as well as some sample data incl. how your data model looks like? Because depending on your data mpdel looks like its possible that the emasure has to be adjsuted.

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.