Repository navigation
Guard monthly cost change against a zero prior month - #2327
Open
Roland Krummenacher (RolandKrummenacher) wants to merge 5 commits into
Open
Roland Krummenacher (RolandKrummenacher) wants to merge 5 commits into
Roland Krummenacher (RolandKrummenacher) wants to merge 5 commits into
Conversation
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 <noreply@anthropic.com>
Roland Krummenacher (RolandKrummenacher)
requested review from
Brett Wilson (MSBrett) and
Michael Flanakin (flanakin)
as code owners
September 16, 2026 13:13
This was referenced Sep 16, 2026
Roland Krummenacher (RolandKrummenacher)
requested a deployment
to
ftk-fork
September 16, 2026 13:13 — with
GitHub Actions
Waiting
Copilot started reviewing on behalf of
Roland Krummenacher (RolandKrummenacher)
September 16, 2026 13:13
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved issues remain.
Pull request overview
Guards monthly cost change calculations against zero prior-month values to prevent inf results.
Changes:
- Adds zero-denominator guards for billed and effective cost percentages.
- Preserves existing behavior for null and non-zero prior values.
File summaries
| File | Description |
|---|---|
src/queries/catalog/monthly-cost-change-percentage.kql |
Prevents divide-by-zero results in both percentage calculations. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…-by-zero Resolved the ms.date conflict in docs-mslearn/toolkit/changelog.md to today per the repo convention. Changelog body entries from both sides were kept. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…y-zero Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠️ Description
monthly-cost-change-percentage.kqlguards its division withisempty(PreviousBilledCost). That covers the nullprev()returns on the first row, butisempty()is false for0.0, so a prior month of exactly zero falls through — and KQL evaluatesx / 0.0asinfrather than raising, so an infinity is returned as the percentage.Both guards now also test for zero:
The
== 0.0form matches the convention already used inservice-price-benchmarking.kql.A zero prior month is reachable rather than theoretical:
BilledCostis zero on usage rows covered by a commitment discount, since the charge was billed at purchase time and the amortized amount lands inEffectiveCost. A scope whose month is entirely commitment-covered therefore sumsBilledCostto exactly zero.Deliberately out of scope: returning
0.0when there is no prior month conflates "no change" with "nothing to compare against".real(null)would separate them, but that is a behaviour change for existing consumers, so this PR only closes the divide-by-zero hole. Happy to follow up if you would prefer the stricter version.Fixes #2323
📋 Checklist
🔬 How did you test this change?
Ran the pipeline's shape against a live ADX hub with a
datatable, so no ingestion is involved:Rows with a non-zero prior month are unaffected, so the change is limited to the case that was previously returning an infinity.
📦 Deploy to test?
Not needed — the change is one query file in the catalog.
🙋♀️ Do any of the following that apply?
📑 Did you update
docs/changelog.md?Added under FinOps hubs → Fixed in
docs-mslearn/toolkit/changelog.md.📖 Did you update documentation?
🤖 Generated with Claude Code