Fix Power BI "Number of Months" parameter causing incorrect date range calculation#1852
Merged
Conversation
Co-authored-by: MSBrett <24294904+MSBrett@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Power BI report excluding first 5 days in March
Fix Power BI "Number of Months" parameter causing incorrect date range calculation
Oct 10, 2025
flanakin
approved these changes
Jan 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an off-by-one error in the Power BI "Number of Months" parameter calculation that was causing reports to pull data from one extra month than intended. When users set the parameter to 3 (expecting 3 closed months + current month = 4 months of data), the report was incorrectly pulling 5 months of data due to an extra +1 in the date calculation formula.
Key changes:
- Removed incorrect
+1offset from date calculation formulas in 5 locations across storage-based and KQL-based Power BI datasets - Updated changelog to document the fix under Power BI reports v13
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/power-bi/storage/Shared.Dataset/definition/expressions.tmdl | Fixed date calculation in two locations: START HERE display and ftk_Storage function |
| src/power-bi/storage/Shared.Dataset/definition/tables/StorageData.tmdl | Fixed date calculation in StorageData table date filter logic |
| src/power-bi/kql/Shared.Dataset/definition/expressions.tmdl | Fixed date calculation in START HERE display for KQL-based reports |
| src/power-bi/kql/Shared.Dataset/definition/tables/StorageData.tmdl | Fixed date calculation in StorageData table date filter logic for KQL-based reports |
| docs-mslearn/toolkit/changelog.md | Documented the bug fix under Power BI reports v13 with issue reference |
flanakin
added a commit
that referenced
this pull request
Jan 31, 2026
…e calculation (#1852) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MSBrett <24294904+MSBrett@users.noreply.github.com> Co-authored-by: Michael Flanakin <flanakin@users.noreply.github.com>
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.
Problem
When users set the "Number of Months" parameter to 3 in Power BI Cost Analysis reports, the report was pulling data from 5 months instead of the expected 4 months (3 closed months + current month). This made it appear that the first 5 days of certain months were missing from the analysis.
Root Cause
The date calculation formula had an off-by-one error with an extra
+1in the month offset:Before (buggy):
After (fixed):
Example
When running the report in October 2024 with
Number of Months = 3:Solution
Removed the incorrect
+1offset from all date calculation formulas across 5 locations in the Power BI datasets:This fix aligns the code with the official documentation:
Testing
This is a pure mathematical correction with no logic changes. Manual validation can be performed by:
Files Changed
src/power-bi/storage/Shared.Dataset/definition/expressions.tmdl(2 changes)src/power-bi/storage/Shared.Dataset/definition/tables/StorageData.tmdl(1 change)src/power-bi/kql/Shared.Dataset/definition/expressions.tmdl(1 change)src/power-bi/kql/Shared.Dataset/definition/tables/StorageData.tmdl(1 change)docs-mslearn/toolkit/changelog.md(documented the fix)Fixes #1833
Original prompt
Fixes #1839
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.