From 8f05194f1963156180a5273d93336d98eac551be Mon Sep 17 00:00:00 2001 From: Roland Krummenacher Date: Wed, 16 Sep 2026 14:56:55 +0200 Subject: [PATCH] fix(queries): guard monthly cost change against a zero prior month isempty() is false for 0.0, so the existing guard only covers the first row, where prev() returns null. A month whose prior month summed to exactly zero falls through and KQL evaluates x / 0.0 to inf rather than raising an error, so the result reaches the caller as an infinity. Co-Authored-By: Claude Opus 5 --- src/queries/catalog/monthly-cost-change-percentage.kql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/queries/catalog/monthly-cost-change-percentage.kql b/src/queries/catalog/monthly-cost-change-percentage.kql index 0e36c8fbd..ea4664337 100644 --- a/src/queries/catalog/monthly-cost-change-percentage.kql +++ b/src/queries/catalog/monthly-cost-change-percentage.kql @@ -22,5 +22,5 @@ Costs() | extend PreviousBilledCost = prev(BilledCost) | extend PreviousEffectiveCost = prev(EffectiveCost) | project ChargePeriodStart, - BilledCostChangePct = iff(isempty(PreviousBilledCost), 0.0, toreal((BilledCost - PreviousBilledCost) * 100.0 / PreviousBilledCost)), - EffectiveCostChangePct = iff(isempty(PreviousEffectiveCost), 0.0, toreal((EffectiveCost - PreviousEffectiveCost) * 100.0 / PreviousEffectiveCost)) \ No newline at end of file + BilledCostChangePct = iff(isempty(PreviousBilledCost) or PreviousBilledCost == 0.0, 0.0, toreal((BilledCost - PreviousBilledCost) * 100.0 / PreviousBilledCost)), + EffectiveCostChangePct = iff(isempty(PreviousEffectiveCost) or PreviousEffectiveCost == 0.0, 0.0, toreal((EffectiveCost - PreviousEffectiveCost) * 100.0 / PreviousEffectiveCost)) \ No newline at end of file