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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Nested SUMIFS column in PowerBI

Hi, I have a table that looks like this:

 

DateCodeValueAdjusted value
01-01-2020VAT2020
01-01-2020Total short-term debt-100-120
01-02-2020VAT100100
01-02-2020Total short-term debt-50-150
01-03-2020VAT5050
01-03-2020Total short-term debt-75-125

 

I want to subtract the positive "VAT" rows from the "Total short-term debt" rows in an "Adjusted value" column whenever the month is the same, but only for "Total short-term debt" rows and not any other rows.

 

In Excel, I would do it like this: 

 

=IF(B2="Total short-term debt";C2-SUMIFS($C$1:$C$7;$A$1:$A$7;A2;$B$1:$B$7;"VAT");C2)

 

How can I do something similar in a custom column in PowerBI?

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

Please try to create a column

Column = if('Table'[Code]="Total short-term debt",'Table'[Value]-sumx(FILTER('Table','Table'[Date]=EARLIER('Table'[Date])&&'Table'[Code]="VAT"),'Table'[Value]),'Table'[Value])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@Anonymous 

Please try to create a column

Column = if('Table'[Code]="Total short-term debt",'Table'[Value]-sumx(FILTER('Table','Table'[Date]=EARLIER('Table'[Date])&&'Table'[Code]="VAT"),'Table'[Value]),'Table'[Value])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

This one did the trick for my particular purpose. Thank you!
Fowmy
Super User
Super User

@Anonymous 

Add this as a custom column in your table in the model.

 

Adj Value = 
IF( Table4[Code] = "Total short-term debt",
    CALCULATE(
    SUMX(
        Table4,
        ABS(Table4[Value])
    ),
    ALLEXCEPT(Table4, Table4[Date])
    ),
Table4[Value]
)

 



________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors