Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I am attempting to build a gains and losses report for my company that can be filtered by month. It needs to list each site that we have, their status at the beginning or end of the month, and whether or not that changed during the month. Sites are either commissioned or decomissioned, but a site that is decomissioned can be recomissioned, because of this our database has a seperate log for these changes. I'm currently stuck trying to make the measure I need for the sites Brought Forward.
I need to see the number of sites that were commissioned at the start of the selected month (currently selected through a slicer on the Month table, linked only through the measure itself), so I need to pull the most recent commissioning time before the start of the month. To do this I've written the following:
Solved! Go to Solution.
Hi @jbranch - very close, can you try the below logic:
Sites Brought Forward =
VAR st = MAX('Month'[Start]) -- selected month's start
-- Step 1: filter events BEFORE selected month
VAR EventsBeforeMonth =
FILTER (
Commissioning,
Commissioning[evtime] < st
)
-- Step 2: get the latest event per Site before the month
VAR LatestPerSite =
ADDCOLUMNS (
SUMMARIZE (EventsBeforeMonth, Commissioning[SiteID]),
"LatestTime", CALCULATE (
MAX (Commissioning[evtime]),
FILTER (
EventsBeforeMonth,
Commissioning[SiteID] = EARLIER (Commissioning[SiteID])
)
)
)
-- Step 3: bring in the corresponding status for that event
VAR WithStatus =
ADDCOLUMNS (
LatestPerSite,
"Status", CALCULATE (
MAX (Commissioning[evqual]),
FILTER (
Commissioning,
Commissioning[SiteID] = EARLIER (Commissioning[SiteID]) &&
Commissioning[evtime] = [LatestTime]
)
)
)
-- Step 4: count how many had "Commissioned" as latest status
RETURN
COUNTROWS (
FILTER (WithStatus, [Status] = "Commissioned")
)
Hope this measure will return the number of sites that were last set to “Commissioned” before the selected month, i.e. the correct "Brought Forward" value.
Proud to be a Super User! | |
Hi @jbranch - very close, can you try the below logic:
Sites Brought Forward =
VAR st = MAX('Month'[Start]) -- selected month's start
-- Step 1: filter events BEFORE selected month
VAR EventsBeforeMonth =
FILTER (
Commissioning,
Commissioning[evtime] < st
)
-- Step 2: get the latest event per Site before the month
VAR LatestPerSite =
ADDCOLUMNS (
SUMMARIZE (EventsBeforeMonth, Commissioning[SiteID]),
"LatestTime", CALCULATE (
MAX (Commissioning[evtime]),
FILTER (
EventsBeforeMonth,
Commissioning[SiteID] = EARLIER (Commissioning[SiteID])
)
)
)
-- Step 3: bring in the corresponding status for that event
VAR WithStatus =
ADDCOLUMNS (
LatestPerSite,
"Status", CALCULATE (
MAX (Commissioning[evqual]),
FILTER (
Commissioning,
Commissioning[SiteID] = EARLIER (Commissioning[SiteID]) &&
Commissioning[evtime] = [LatestTime]
)
)
)
-- Step 4: count how many had "Commissioned" as latest status
RETURN
COUNTROWS (
FILTER (WithStatus, [Status] = "Commissioned")
)
Hope this measure will return the number of sites that were last set to “Commissioned” before the selected month, i.e. the correct "Brought Forward" value.
Proud to be a Super User! | |
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!