Forum Discussion
ddalton
Resolver I
4 years agoCreate new table that sums rows based on matching column value
I have a table containing data with columns containing a reference (non-unique) and a type (non-unique). A representation is below: TableA Reference Type Value A123 Type1 5521 A123 ...
- 4 years ago
ddalton create this calculated table:
TableB = ADDCOLUMNS( VALUES('TableA'[Reference]), "Type1", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type1"), "Type2", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type2") )
ddalton
Resolver I
4 years agoAh. No, there is more than one reference per customer. I've updated the original reply above to include, for example, reference C231 and show that is also linked to Cust AAA.
So, there is multiple references per customer.
SpartaBI
Community Champion
4 years agoddalton you mean like this? :
TableB =
ADDCOLUMNS(
ALL('TableA'[Reference], TableA[Cust]),
"Type1", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type1"),
"Type2", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type2")
)
- ddalton4 years ago
Resolver I
Exactly like that. Thank you!
- SpartaBI4 years ago
Community Champion
ddalton my pleasure 🙂
Don't forget about the report please 🤣.
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂