# Calculating availability

The reports for the ProductAvailabilityToSell.ShipNodeChange and DgAvailabilityChange events have total availability, which includes safety stock that is withheld.
If you want to calculate the availability without considering safety stock, then you can manually compute the availability with the following formula.
``Total availability without considering safety stock = totalAvailableQuantity - totalShortageQuantity + totalSafetyStockWithheld``

## Calculating availability without safety stock example 1

Assume on hand supply = 4, safety stock = 2, and demand = 3.
``````onhandAvailableQuantity=0
futureAvailableQuantity=0
totalAvailableQuantity=0
onhandSafetyQuantityWithheld=1
futureSafetyQuantityWithheld=0
totalSafetyQuantityWithheld=1
totalReservedQuantity=0
totalShortageQuantity=0``````
• onhandSafetyQuantityWithheld and futureSafetyQuantityWithheld values are quantities that can be allocated from the respective onhandAvailableQuantity and futureAvailableQuantity values.
• Demand takes 3 from on hand supply, which leaves 1 on hand supply. The on hand supply of 1 is allocated to the onhandSafetyQuantityWithheld. Therefore, onhandSafetyQuantityWithheld=1 and onhandAvailableQuantity=0.
• totalSafetyQuantityWithheld is onhandSafetyQuantityWithheld + futureSafetyQuantityWithheld. Therefore, totalSafetyQuantityWithheld=1.
• totalAvailableQuantity is onhandAvailableQuantity + futureAvailableQuantity. Therefore, totalAvailableQuantity=0.
• totalShortageQuantity is used as a dummy variable and always returns 0.

Availability without considering safety stock = totalAvailableQuantity - totalShortageQuantity + totalSafetyQuantityWithheld = 0 - 0 + 1 = 1

## Calculating availability without safety stock example 2

Assume on hand supply = 5, future supply = 13, safety stock = 9, demand = 0, reservation = 0.
``````onhandAvailableQuantity=0
futureAvailableQuantity=9
totalAvailableQuantity=9
onhandSafetyQuantityWithheld=5
futureSafetyQuantityWithheld=4
totalSafetyQuantityWithheld=9
totalReservedQuantity=0
totalShortageQuantity=0``````
• On hand supply of 5 is allocated to the onhandSafetyQuantityWithheld. Therefore, onhandSafetyQuantityWithheld=5 and onhandAvailableQuantity=0.
• From the future supply of 13, 4 is allocated to futureSafetyQuantityWithheld. Therefore, futureSafetyQuantityWithheld=4 and futureAvailableQuantity=9.
• totalAvailableQuantity is onhandAvailableQuantity + futureAvailableQuantity. Therefore, totalAvailableQuantity=9.
• totalSafetyQuantityWithheld is onhandSafetyQuantityWithheld + futureSafetyQuantityWithheld. Therefore, totalSafetyQuantityWithheld=9.
• totalShortageQuantity=0 is used as a dummy variable and always returns 0.

Availability without considering safety stock as totalAvailableQuantity - totalShortageQuantity + totalSafetyStockWithheld = 9 - 0 + 9 = 18