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
mrothschild
Continued Contributor
Continued Contributor

SUMPRODUCT IFS?

I am using the following expression to get a SUMPRODUCT measure, which gives me the weighted average [Interest Rate] based on [Capital].  

 

In some cases, [Interest Rate] = 0 because there's no loan outstanding, but the expression then has too high a denominator.  If I insert 

 
,FILTER(SummaryInputTable,SummaryInputTable[Interest Rate]>0)
 
into the denominator CALCULATE, I get a really screwed up number.  Example Data and desired output is below:

 

WAVG Interest Rate =
VAR __CATEGORY_VALUES = VALUES('SummaryInputTable'[Asset ID])
RETURN
    DIVIDE(
        SUMX(
            KEEPFILTERS(__CATEGORY_VALUES),
            CALCULATE(
                SUM('SummaryInputTable'[Interest Rate])
                    * SUM('SummaryInputTable'[Capital])
            )
        ),
        SUMX(
            KEEPFILTERS(__CATEGORY_VALUES),
            CALCULATE(SUM('SummaryInputTable'[Capital]))
        )
    )
 
 
Asset IDCapitalInterest Rate
A22009%
B33305%
J16000%
   
 Desired Output6.59%
 Current Output5.11%
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@mrothschild  - The following Measure should work. It first removes the 0-interest rows and then performs the weighted average.

Weighted = 
var _desired_rows = FILTER(Rates, Rates[Interest Rate] > 0)
return DIVIDE(
    SUMX(_desired_rows,[Interest Rate] * [Capital]),
    SUMX(_desired_rows,[Capital])
)
I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@mrothschild  - The following Measure should work. It first removes the 0-interest rows and then performs the weighted average.

Weighted = 
var _desired_rows = FILTER(Rates, Rates[Interest Rate] > 0)
return DIVIDE(
    SUMX(_desired_rows,[Interest Rate] * [Capital]),
    SUMX(_desired_rows,[Capital])
)
I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.

 

Thanks so much - works perfectly!

 

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.