From 306a9628f185fe88f7369be0d31a52a1921990b9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Oct 2025 20:29:14 +0000 Subject: [PATCH 1/2] Initial plan From e0f84037f46303f2806754029a2fdc4ec98403f2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Oct 2025 20:38:33 +0000 Subject: [PATCH 2/2] Fix Number of Months date calculation bug Co-authored-by: MSBrett <24294904+MSBrett@users.noreply.github.com> --- docs-mslearn/toolkit/changelog.md | 1 + src/power-bi/kql/Shared.Dataset/definition/expressions.tmdl | 2 +- .../kql/Shared.Dataset/definition/tables/StorageData.tmdl | 2 +- .../storage/Shared.Dataset/definition/expressions.tmdl | 4 ++-- .../storage/Shared.Dataset/definition/tables/StorageData.tmdl | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs-mslearn/toolkit/changelog.md b/docs-mslearn/toolkit/changelog.md index 7c5d94e4b..f27219854 100644 --- a/docs-mslearn/toolkit/changelog.md +++ b/docs-mslearn/toolkit/changelog.md @@ -45,6 +45,7 @@ The following section lists features and enhancements that are currently in deve - **Fixed** - Fixed tag expansion in Power BI reports when tag names contain special characters like colons. + - Fixed "Number of Months" parameter calculation that was excluding the first 5 days of data when set to 3 months ([#1833](https://github.com/microsoft/finops-toolkit/issues/1833)). ### [FinOps hubs](hubs/finops-hubs-overview.md) v13 diff --git a/src/power-bi/kql/Shared.Dataset/definition/expressions.tmdl b/src/power-bi/kql/Shared.Dataset/definition/expressions.tmdl index 8462dbca5..81cf35cf5 100644 --- a/src/power-bi/kql/Shared.Dataset/definition/expressions.tmdl +++ b/src/power-bi/kql/Shared.Dataset/definition/expressions.tmdl @@ -22,7 +22,7 @@ expression '▶️ START HERE' = ``` DateEnd = null, DateStart = null, DateMonths = #"Number of Months", - DateStartEffective = if DateStart <> null and DateStart <> "" then DateStart else Date.AddMonths(if DateEnd <> null and DateEnd <> "" then DateEnd else Date.AddMonths(Date.StartOfMonth(DateTime.LocalNow()), 1), -DateMonths+1), + DateStartEffective = if DateStart <> null and DateStart <> "" then DateStart else Date.AddMonths(if DateEnd <> null and DateEnd <> "" then DateEnd else Date.AddMonths(Date.StartOfMonth(DateTime.LocalNow()), 1), -DateMonths), _formatDate = (d) => try DateTime.ToText(d, [Format="MMM d, yyyy"]) otherwise d, DateStartFormat = if (DateStart = null or DateStart = "") and (DateMonths = null or DateMonths < 1) then "*" diff --git a/src/power-bi/kql/Shared.Dataset/definition/tables/StorageData.tmdl b/src/power-bi/kql/Shared.Dataset/definition/tables/StorageData.tmdl index 71037ccca..7c617c9a1 100644 --- a/src/power-bi/kql/Shared.Dataset/definition/tables/StorageData.tmdl +++ b/src/power-bi/kql/Shared.Dataset/definition/tables/StorageData.tmdl @@ -266,7 +266,7 @@ table StorageData end = if RangeEnd <> null then Date.From(RangeEnd, Culture.Current) else null, start = if RangeStart <> null then Date.From(RangeStart, Culture.Current) - else if #"Number of Months" <> null and #"Number of Months" > 0 then Date.AddMonths(if end <> null then end else Date.StartOfMonth(Date.From(DateTime.LocalNow())), -(#"Number of Months"+1)) + else if #"Number of Months" <> null and #"Number of Months" > 0 then Date.AddMonths(if end <> null then end else Date.StartOfMonth(Date.From(DateTime.LocalNow())), -#"Number of Months") else null, FilterFilesByDate = if start = null and end = null then InitialDetails diff --git a/src/power-bi/storage/Shared.Dataset/definition/expressions.tmdl b/src/power-bi/storage/Shared.Dataset/definition/expressions.tmdl index b6685af8f..98873d2dc 100644 --- a/src/power-bi/storage/Shared.Dataset/definition/expressions.tmdl +++ b/src/power-bi/storage/Shared.Dataset/definition/expressions.tmdl @@ -58,7 +58,7 @@ expression '▶️ START HERE' = ``` DateEnd = RangeEnd, DateStart = RangeStart, DateMonths = #"Number of Months", - DateStartEffective = if DateStart <> null and DateStart <> "" then DateStart else Date.AddMonths(if DateEnd <> null and DateEnd <> "" then DateEnd else Date.AddMonths(Date.StartOfMonth(DateTime.LocalNow()), 1), -DateMonths+1), + DateStartEffective = if DateStart <> null and DateStart <> "" then DateStart else Date.AddMonths(if DateEnd <> null and DateEnd <> "" then DateEnd else Date.AddMonths(Date.StartOfMonth(DateTime.LocalNow()), 1), -DateMonths), _formatDate = (d) => try DateTime.ToText(d, [Format="MMM d, yyyy"]) otherwise d, DateStartFormat = if (DateStart = null or DateStart = "") and (DateMonths = null or DateMonths < 1) then "*" @@ -127,7 +127,7 @@ expression ftk_Storage = ``` end = if RangeEnd <> null then Date.From(RangeEnd, Culture.Current) else null, start = if RangeStart <> null then Date.From(RangeStart, Culture.Current) - else if #"Number of Months" <> null and #"Number of Months" > 0 then Date.AddMonths(if end <> null then end else Date.StartOfMonth(Date.From(DateTime.LocalNow())), -(#"Number of Months"+1)) + else if #"Number of Months" <> null and #"Number of Months" > 0 then Date.AddMonths(if end <> null then end else Date.StartOfMonth(Date.From(DateTime.LocalNow())), -#"Number of Months") else null, data = if datasetType <> null and datasetType <> "" then Text.Lower(datasetType) else "focuscost", diff --git a/src/power-bi/storage/Shared.Dataset/definition/tables/StorageData.tmdl b/src/power-bi/storage/Shared.Dataset/definition/tables/StorageData.tmdl index 43eb716b3..8c1d26051 100644 --- a/src/power-bi/storage/Shared.Dataset/definition/tables/StorageData.tmdl +++ b/src/power-bi/storage/Shared.Dataset/definition/tables/StorageData.tmdl @@ -266,7 +266,7 @@ table StorageData end = if RangeEnd <> null then Date.From(RangeEnd, Culture.Current) else null, start = if RangeStart <> null then Date.From(RangeStart, Culture.Current) - else if #"Number of Months" <> null and #"Number of Months" > 0 then Date.AddMonths(if end <> null then end else Date.StartOfMonth(Date.From(DateTime.LocalNow())), -(#"Number of Months"+1)) + else if #"Number of Months" <> null and #"Number of Months" > 0 then Date.AddMonths(if end <> null then end else Date.StartOfMonth(Date.From(DateTime.LocalNow())), -#"Number of Months") else null, FilterFilesByDate = if start = null and end = null then InitialDetails