The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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
ID | Account | Value | Transaction ID |
1 | 11000 | 2000 | a |
2 | 11000 | 3000 | b |
3 | 2000 | -2000 | a |
4 | 2000 | 4000 | c |
5 | 11000 | 5000 | d |
6 | 2000 | -5000 | d |
7 | 3000 | 2000 | e |
8 | 4000 | 3000 | f |
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.
Solved! Go to Solution.
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
Proud to be a Super User!
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
Proud to be a Super User!
Worked Great - Thanks!
Mark
Proud to be a Super User!
User | Count |
---|---|
25 | |
10 | |
8 | |
6 | |
6 |
User | Count |
---|---|
31 | |
12 | |
10 | |
10 | |
9 |