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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
Anonymous
Not applicable

Calculated Column - Diff between Current Row Value and Conditional Lookup Row Value

Hi,

 

I'm trying to create a Calculated Column in PowerBI that provides me with the result shown in Table A, Column "ActiveWeight_vs_AAA" below. 

 

This is a simple conditional sumif calculation: security weight in the current row minus security weight in portfolio AAA. If I was using Excel I would write and drag down the formula as:

=C2-SUMIFS($C:$C, $A:$A,"AAA", $B:$B, B2)

 

Examples:

(1) In Table A/Row 2, [ActiveWeight_vs_AAA] = 5%-5% = 0%.

(3) In Table A/Row 4, [ActiveWeight_vs_AAA] = 8%-5% = 3%.

(3) In Table A/Row 6, [ActiveWeight_vs_AAA] = 18%-0% = 18%.

 

It feels like it should be very straight forward but I am struggling. Any thoughts would be sincerely appreciated. 

(Also any advice on Calculated Column vs. Measure would be useful - for instance, it would be great to have Portfolio AAA controlled by a portfolio dropdown slicer in the PowerBI dashboard).

 

Table A

PortfolioSecurityIDWeightActiveWeight_vs_AAA
AAAbond_15%0%
BBBbond_11%-4%
CCCbond_18%3%
DDDbond_110%5%
BBBbond_218%18%
CCCbond_215%15%
DDDbond_210%10%

 

1 ACCEPTED SOLUTION
ChandeepChhabra
Impactful Individual
Impactful Individual

@Anonymous 

Try this column formula

 

 

Column = 
'Dataset'[Weight]-
SUMX(
    FILTER(
        ALL('Dataset'),
        'Dataset'[Portfolio]="AAA"&&
        'Dataset'[SecurityID]=EARLIER('Dataset'[SecurityID])
    ),
        'Dataset'[Weight]
)

 

Picture1.png

 

Thanks

 

View solution in original post

2 REPLIES 2
ChandeepChhabra
Impactful Individual
Impactful Individual

@Anonymous 

For making it dynamic through a slicer, please refer to the Power BI file

 

Picture1.png

 

Hope this helps

Thanks

ChandeepChhabra
Impactful Individual
Impactful Individual

@Anonymous 

Try this column formula

 

 

Column = 
'Dataset'[Weight]-
SUMX(
    FILTER(
        ALL('Dataset'),
        'Dataset'[Portfolio]="AAA"&&
        'Dataset'[SecurityID]=EARLIER('Dataset'[SecurityID])
    ),
        'Dataset'[Weight]
)

 

Picture1.png

 

Thanks

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.