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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
daneilroy
Frequent Visitor

SUMX help to use SUMX where rows from two tables must be subtracted.

Hello everyone

I'm having trouble solving this problem.

 

I have a Transaction table and an item table. 

In my Transaktion tabel i have a lot og columns where i wanna use the 'transaktion amount' and 'transaktion key' 

In the Items table i wanna use the 'transaktion key' and the 'item registration fee' 

I want to sum 'transaction amout', for the whole transaktion table, but where the transaktion wich is registered i the items table as a "court_fee or 'registration' are deducted.

 

So if a transaktion is a court_fee og a registration they should NOT be a part of the sum of the transaktion amount. 

 

I sorted so. both tables are only march 2022 - Where the first photo is the items table and the second is the transaktion table.

 

Screenshot 2022-03-10 at 10.36.16.pngScreenshot 2022-03-10 at 10.36.26.png

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Transaction Amount Measure = SUMX( 'transaction table',
var itemFees = CALCULATE( SUMX( RELATEDTABLE( 'items' ), 'items'[item registration fee]),
NOT( 'items'[item type] IN { "court fee", "registration fee" } )
return itemFees + 'transaction table'[transaction amount]
)

View solution in original post

3 REPLIES 3
tamerj1
Community Champion
Community Champion

@daneilroy 
Would you please share a screenshot of your data model?

johnt75
Super User
Super User

Transaction Amount Measure = SUMX( 'transaction table',
var itemFees = CALCULATE( SUMX( RELATEDTABLE( 'items' ), 'items'[item registration fee]),
NOT( 'items'[item type] IN { "court fee", "registration fee" } )
return itemFees + 'transaction table'[transaction amount]
)

Hello John! 

Thank you very much! it worked! i just had to do some formating but everything else is perfect. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.