Service Level calc mismatch with /analytics/conversations/queues/real-time/intervals

I’m trying to calculate SLA from the raw interval data returned by the real-time analytics endpoint. The JSON gives me offered and answeredWithin30Seconds, but dividing the two doesn’t match the dashboard value.

c# var sl = (double)interval.AnsweredWithin30Seconds / interval.Offered;

The result is way too high. Is there a specific weighting or a different field I need to use for the denominator?

Don’t use offered. That includes every call that hit the queue, even abandoned ones. Use answered as the denominator.

var sl = (double)interval.AnsweredWithin30Seconds / interval.Answered;

The point above is correct, but you’ll still get NaN if answered is zero. Guard against it.

var sl = interval.Answered > 0 ? (double)interval.AnsweredWithin30Seconds / interval.Answered : 0;