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

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.

Reply
stb130130
Regular Visitor

Weighted Average by filtered Category

Hello, 
 
I am trying to create a weighted average based on a filtered measure from a live connected model. As of now, I have created the below measure but am having trouble aggreating the total of weights to aggregate by PM. I am instead getting individual values that total to the weights which does make sense. That said, is there a way to bring in the total vs the individual amounts being calcualted. 
 
My aim is to get to the 132,014 seen in the excel snapshot. 
 
EAC X and EAC Revenue are both measures. 
 
In Excel Example
 
 
stb130130_0-1682973926234.png

 

 

BI Results

 stb130130_1-1682973925969.png

 

 

 

 

 
 
Weighting by Project =
VAR ProjectEACRevenue =
CALCULATE(
    [.EAC Revenue],
    ALLEXCEPT(Projects,Projects[Project Number])
)
VAR ProjectManagerRevenue =
CALCULATE(
    [.EAC Revenue],
    ALLEXCEPT(Projects,Projects[Project Manager])
)
VAR Weights =
DIVIDE(ProjectEACRevenue, ProjectManagerRevenue)
VAR Weighting =
Weights *
CALCULATE(
    [X],
    (ALLEXCEPT(Projects,Projects[Project Number])
    )
)
RETURN Weighting
1 ACCEPTED SOLUTION

Well I ended up just creating dataset and making the measure. 
 
Weighted Average  =
SUMX(
    VALUES('PFM'[Project Manager]),
    VAR PMTotalRevenue = SUMX(FILTER('PFM', 'PFM'[Project Manager] = 'PFM'[Project Manager]), 'PFM'[.EAC Revenue])
    RETURN
    SUMX(
        FILTER('PFM', 'PFM'[Project Manager] = 'PFM'[Project Manager]),
        DIVIDE('PFM'[.EAC Revenue], PMTotalRevenue) * RELATED('X'[X])
    )
)

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@stb130130 , I think it should be like

 

VAR Weighting =
Sumx
(Values(Projects,Projects[Project Number]),calculate( [X]*Weights)
)

Well I ended up just creating dataset and making the measure. 
 
Weighted Average  =
SUMX(
    VALUES('PFM'[Project Manager]),
    VAR PMTotalRevenue = SUMX(FILTER('PFM', 'PFM'[Project Manager] = 'PFM'[Project Manager]), 'PFM'[.EAC Revenue])
    RETURN
    SUMX(
        FILTER('PFM', 'PFM'[Project Manager] = 'PFM'[Project Manager]),
        DIVIDE('PFM'[.EAC Revenue], PMTotalRevenue) * RELATED('X'[X])
    )
)

Thanks - I tried it and am getting the same values as I was before. I think I might need to so sumx filtered as of the variables as I am not bringing in values when I remove project number. 

 

Weighting by Project =
VAR ProjectEACRevenue =
CALCULATE(
    [.EAC Revenue],
    ALLEXCEPT(Projects,Projects[Project Number])
)
VAR ProjectManagerRevenue =
CALCULATE(
    [.EAC Revenue],
    ALLEXCEPT(Projects,Projects[Project Manager])
)
VAR Weights =
DIVIDE(ProjectEACRevenue, ProjectManagerRevenue)
VAR Weighting =
Sumx
(Values(Projects[Project Manager]),calculate( [X]*Weights)
)
RETURN Weighting
 
 
stb130130_2-1683060949862.pngstb130130_3-1683060963506.png

 


 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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