Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register 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 April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
78 | |
76 | |
70 | |
49 | |
42 |
User | Count |
---|---|
62 | |
40 | |
32 | |
30 | |
29 |