cancel
Showing results for
Did you mean:
Helper I

## 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
Community Support

You can try the following methods.

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 ()
)
)``````

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.

3 REPLIES 3
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
Community Support

You can try the following methods.

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 ()
)
)``````

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.

Resident Rockstar

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.

------------------------------------------------------------------
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!

Announcements

#### Power BI Community Changes

Check out the changes to the Power BI Community announced at Build.

#### Power BI May 2023 Update

Find out more about the May 2023 update.