Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I have the following measure calculating project progress.
RPnew =
VAR StatusDate = [StatusDate]
VAR Result =
CALCULATE (
SUMX (
FILTER ( RP, RP[Group] = "Design" ),
RP[Progress] * RELATED ( IW[Weighting] )
* RELATED ( GW[Weighting] )
)
+ SUMX (
FILTER ( RP, RP[Group] = "Purchasing" ),
RP[Progress] * RELATED ( IW[Weighting] )
* RELATED ( GW[Weighting] )
)
+ SUMX (
FILTER ( RP, RP[Group] = "Construction" ),
RP[Progress] * RELATED ( IW[Weighting] )
* RELATED ( GW[Weighting] )
)
+ SUMX (
FILTER ( RP, RP[Group] = "Commissioning" ),
RP[Progress] * RELATED ( IW[Weighting] )
* RELATED ( GW[Weighting] )
),
RP[Date] <= EOMONTH ( StatusDate, 0 )
)
RETURN
Result
I have progress data beyond the Status date (which is 31.08.2021) in this case, this is why I have to limit the calculation within the Status date which is working. This is the result:
Even though progress data is available also after 31.08.2021 it show only data within that date.
To make the code more readable I wanted to use variables.
RPnew =
VAR StatusDate = [StatusDate]
VAR DRP =
SUMX (
FILTER ( RP, RP[Group] = "Design" ),
RP[Progress] * RELATED ( IW[Weighting] )
* RELATED ( GW[Weighting] )
)
VAR PRP =
SUMX (
FILTER ( RP, RP[Group] = "Purchasing" ),
RP[Progress] * RELATED ( IW[Weighting] )
* RELATED ( GW[Weighting] )
)
VAR CRP =
SUMX (
FILTER ( RP, RP[Group] = "Construction" ),
RP[Progress] * RELATED ( IW[Weighting] )
* RELATED ( GW[Weighting] )
)
VAR COMRP =
SUMX (
FILTER ( RP, RP[Group] = "Commissioning" ),
RP[Progress] * RELATED ( IW[Weighting] )
* RELATED ( GW[Weighting] )
)
VAR RealProgress = DRP + PRP + CRP + COMRP
VAR Result =
CALCULATE ( RealProgress, RP[Date] <= EOMONTH ( StatusDate, 0 ) )
RETURN
Result
However with this code the calculation is not anymore limited to the Status date which is 31.08.2021 and I don't understand why.
Thanks in advance
Br
Any particular reason for using RELATED() in a measure?
You can also simplify your filter quite a bit
FILTER ( RP, RP[Group] IN {"Design","Purchasing","Construction","Commissioning"} )
Hi @lbendlin,
this is my data model
The table IW and GW are on the one side of the relationship to RP this is why I'm using RELATED() to access the Weighting values in IW and GW.
Hi,
any suggestions as to why the same formula works without but does not work using variables?
Br
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
100 | |
81 | |
70 | |
62 |
User | Count |
---|---|
148 | |
116 | |
104 | |
90 | |
65 |