Forum Discussion
Multiply columns from 2 tables by using a measure
Table A:
| PartNo | RefNo | Type | PartQty |
| A123 | 3532-421 | X | 5 |
| B234 | 5754-643 | Y | 3 |
| C342 | 4362-346 | X | 2 |
| A352 | 6853-435 | Z | 6 |
Table B
| RefNo | Period | RefQty |
| 3532-421 | M1 | 100 |
| 6853-435 | M1 | 200 |
| 6853-435 | M2 | 50 |
| 4362-346 | M3 | 400 |
I would like to create a measure UseQty.
UseQty = RefQty * PartQty when RefNo (in Table B)= RefNo (in Table A)
Eventually I would like to create charts using Period (Table B), PartNo (Table A), Type(Table A) and UseQty (Measure).
I tried creating an additional column in Table B via PowerQuery but that ended up making the calculation very slow as I have 60k rows in Table A and 400k rows in Table B.
Appreciate your help!!!
Hi Anonymous,
Do you have repeated values on the refno of table A? Asking this because this changes the result you need.
Create a table with the refn.º and make a relationship between this table and the other 2 with a one to many now add the following measure:
TotalQTY = SUMX ( ADDCOLUMNS ( SUMMARIZE ( TableA, Reference[RefNo], TableA[PartNo], "RefQty", SUM ( TableA[PartQty] ) ), "Quantity", CALCULATE ( SUM ( TableB[RefQty] ), TableB[RefNo] IN VALUES ( Reference[RefNo] ) ) ), [RefQty] * [Quantity] )Result below:
1 Reply
- MFelix
Super User
Hi Anonymous,
Do you have repeated values on the refno of table A? Asking this because this changes the result you need.
Create a table with the refn.º and make a relationship between this table and the other 2 with a one to many now add the following measure:
TotalQTY = SUMX ( ADDCOLUMNS ( SUMMARIZE ( TableA, Reference[RefNo], TableA[PartNo], "RefQty", SUM ( TableA[PartQty] ) ), "Quantity", CALCULATE ( SUM ( TableB[RefQty] ), TableB[RefNo] IN VALUES ( Reference[RefNo] ) ) ), [RefQty] * [Quantity] )Result below: