# How is availability calculated in the calendar?

The availability in a calendar is not queryable. Altru doesn’t allow us to query so we found a way to compute it. We need to calculate the availability manually to account accurately the number of particular tickets left. This guide will show you exactly how to calculate availability in the calendar so keep on reading.

## Calculating the availability in the calendar

1: Make sure that you already have the Calendar Query which is the output of all program information. This query gives the number of capacity you have set for a specific event.

2: We also need the Reserved Event Query to calculate the number of tickets sold. The query includes tickets that are sold and not refunded. Under this query, we’re outputting quantity.

3: Grab the capacity that was set based on the result of the calendar query less the number of tickets sold and the difference is the availability. This gives us the formula:

## Calculating Sold

Use the formula above to calculate the availability but before you do that, determine first the number of tickets sold. We will base the total number of tickets sold on the output given by the reserved event query. The query will display the sales order with the total quantity of tickets for a particular event. You can calculate the number of items sold by taking the sum of all quantities in the output query.

By taking the capacity based on the Calendar Query and the quantity calculated by taking the sum of all quantities displayed on the sales order provided by the reserved event query, you can now calculate the number of availability for a calendar.