Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ITManuel
Responsive Resident
Responsive Resident

Issue with time intelligence using variables

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:

 

V1.JPG

 

 

 

 

 

 

 

 

 

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.

 

V2.JPG

 

 

 

 

 

 

 

 

 

Thanks in advance

 

Br

3 REPLIES 3
lbendlin
Super User
Super User

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"} )
ITManuel
Responsive Resident
Responsive Resident

Hi @lbendlin

 

this is my data model 

DataModel.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

DataModel1.png

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.

ITManuel
Responsive Resident
Responsive Resident

Hi,

 

any suggestions as to why the same formula works without but does not work using variables?

 

Br

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.