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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
markpatton
Helper I
Helper I

Dax to sum matched transactions

I'm looking for a measure that will return the sum of matched transactions in a table. 

 

For the following table. I want to sum the values for records with account=2000 that have a corresponding (opposite) value with account = 11000

 

IDAccountValueTransaction ID
1110002000a
2110003000b
32000-2000a
420004000c
5110005000d
62000-5000d
730002000e
840003000f

 

With the measure coded to account 11000 and account 2000 I would want the value to be returned to be -7000. Basically sum of value for row 3 and 6 because they have corresponding values in rows 1 and 5 for account 11000.

1 ACCEPTED SOLUTION
Nathaniel_C
Community Champion
Community Champion

Hi @markpatton , try this

 

 

Matching values =
VAR _11Acct = 11000
VAR _table11 =
    FILTER ( 'Table', 'Table'[Account] = _11Acct )
VAR _2Acct = 2000
VAR _addcolumn =
    CALCULATETABLE (
        ADDCOLUMNS (
            _table11,
            "LOOK", LOOKUPVALUE ( 'Table'[Value], 'Table'[Value], [Value] * -1 )
        ),
        FILTER ( 'Table', 'Table'[Account] = _2Acct )
    )
VAR _sum =
    SUMX ( _addcolumn, [LOOK] )
RETURN
    _sum

 

 


That was fun!
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Capture121.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
Nathaniel_C
Community Champion
Community Champion

Hi @markpatton , try this

 

 

Matching values =
VAR _11Acct = 11000
VAR _table11 =
    FILTER ( 'Table', 'Table'[Account] = _11Acct )
VAR _2Acct = 2000
VAR _addcolumn =
    CALCULATETABLE (
        ADDCOLUMNS (
            _table11,
            "LOOK", LOOKUPVALUE ( 'Table'[Value], 'Table'[Value], [Value] * -1 )
        ),
        FILTER ( 'Table', 'Table'[Account] = _2Acct )
    )
VAR _sum =
    SUMX ( _addcolumn, [LOOK] )
RETURN
    _sum

 

 


That was fun!
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Capture121.PNG

 





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

Proud to be a Super User!




Worked Great  - Thanks!

 

Mark

Capture222.PNG

 





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

Proud to be a Super User!




Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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