# Time and Dates count

Hi!

Thank ypu for your great app!

I have a question:

I need to create table to show service availability

Each time when service is down we create issue with incedent start and end datetime

So no issues means 100%

How can i count availability by date?

Cheers

Hi @vryzhov,
Happy to hear that you are enjoying our app The solution for counting the total service availability time would be summing the time intervals between incident start time and incident end time.

As you create separate issues for each incident event for the system, you need to import the incident start and end date custom fields as properties. Then, the incident time for a specific incident ticket can be calculated using the DateDiffDays function:

``````DateDiffDays(
[Measures].[Issue incident start time],
[Measures].[Issue incident end time]
)
``````

This code can work only at the issue-level, and you need to sum up all the incident tickets with incident start time over the period. The formula would be the following (“Total incident time”):

``````Sum(
Filter(Descendants([Issue].CurrentMember,[Issue].[Issue]),
[Measures].[Issues with incident start time]>0
),
DateDiffDays(
[Measures].[Issue incident start time],
[Measures].[Issue incident end time]
)
)
``````

The total length of the period can be calculated with the same DateDiffDays function (“Total time in period”):

``````DateDiffDays(
[Time].CurrentHierarchyMember.StartDate,
[Time].CurrentHierarchyMember.NextStartDate
)
``````

Now the service availability would be the ratio of incident time vs. total time:

``````1-
[Measures].[Total incident time]/
[Measures].[Total time in period]
``````

Note that this solution has a limitation; it assumes that there are no overlapping incident periods. It will not be possible to implement the solution if the incident periods overlap.

The measures would look like this:

best
Gerda // support@eazybi.com