Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi all I have a table with 2 types of capacity in it and for every record a startdate and enddate. Some dummy data is here:
As you can see there is capacity for a costcenter or capacity for a group. A group is a lower level than a costcenter. This all is based on a very simple starschema.
Now I'm creating measures to show the correct amount of capacity for groups and costcenters. My measures are defined as follows:
CC Capacity =
VAR CurDate = SELECTEDVALUE('Date'[Date])
VAR x = SUMX('Date', MAXX(FILTER(Capacity, NOT(ISBLANK(Capacity[CapacityCC])) && CurDate < Capacity[Enddate] && CurDate >= Capacity[Startdate]), SUM(Capacity[CapacityCC])))
RETURN x
and
Group Capacity =
VAR CurDate = SELECTEDVALUE('Date'[Date])
VAR x = SUMX('Date', MAXX(FILTER(Capacity, NOT(ISBLANK(Capacity[CapacityGroup])) && CurDate < Capacity[Enddate] && CurDate >= Capacity[Startdate]), SUM(Capacity[CapacityGroup])))
RETURN x
But what's wrong here is the output 🤣
I have some examples.
Problem 1
Example 1 is selecting 1 specific data (i.e. 2 february 2021) which is giving me the incorrect amount because it's summing all the records that apply, not only the one that should be active based on there start- and enddate.
38 is the result of 18 + 20 while it should be only 18. And 62 is the sum of 30 and 32 instead of just 30.
Problem 2
Problem 2 is when you don't select 1 specific date but a month it's not showing anything. While I should expect the last empty value for that specific month/group/cc.
Is there a dax-guru here to help me out?
File with my example data and all relevant dimensions can be found here.
Solved! Go to Solution.
You can use
CC Capacity copy =
VAR CurDate = MAX( 'Date'[Date] )
VAR x =
CALCULATE(
SUM( 'Capacity'[CapacityCC] ),
NOT ISBLANK( 'Capacity'[CapacityCC] )
&& CurDate < 'Capacity'[Enddate]
&& CurDate >= 'Capacity'[Startdate]
)
RETURN
x
Group Capacity copy =
VAR CurDate = MAX( 'Date'[Date] )
VAR x =
CALCULATE(
SUM( 'Capacity'[CapacityGroup] ),
NOT ISBLANK( 'Capacity'[CapacityGroup] )
&& CurDate < 'Capacity'[Enddate]
&& CurDate >= 'Capacity'[Startdate]
)
RETURN
x
And if I have an additional wish; I also want to see the numbers for a month where a record stops as well? So by example the line with enddate 25-12-2023 must be visible in december 2023 as well. I've tried some things but for the situation where a new line follows up with start 26-12-2023 I go double...
You can use
CC Capacity copy =
VAR CurDate = MAX( 'Date'[Date] )
VAR x =
CALCULATE(
SUM( 'Capacity'[CapacityCC] ),
NOT ISBLANK( 'Capacity'[CapacityCC] )
&& CurDate < 'Capacity'[Enddate]
&& CurDate >= 'Capacity'[Startdate]
)
RETURN
x
Group Capacity copy =
VAR CurDate = MAX( 'Date'[Date] )
VAR x =
CALCULATE(
SUM( 'Capacity'[CapacityGroup] ),
NOT ISBLANK( 'Capacity'[CapacityGroup] )
&& CurDate < 'Capacity'[Enddate]
&& CurDate >= 'Capacity'[Startdate]
)
RETURN
x
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |