Forum Discussion
hasanhilmi
3 years agoFrequent Visitor
Calculating Purchase Quantities under Purchase Agreement
Hi everyone! New to the board and excited to learn. I have two tables, PurchaseAgreement and PurchaseOrderTransactions. What I want is to sum the purchase quantities I have generated under each...
- Anonymous3 years ago
Hi hasanhilmi ,
Here I suggest you to create a calculated column by this code.
Quantity = CALCULATE ( SUM ( PurchaseOrderTransactions[Quantity] ), FILTER ( PurchaseOrderTransactions, PurchaseOrderTransactions[Vendor] = EARLIER ( PurchaseAgreement[Vendor] ) && PurchaseOrderTransactions[Item] = EARLIER ( PurchaseAgreement[Item] ) && PurchaseOrderTransactions[Warehouse] = EARLIER ( PurchaseAgreement[Warehouse] ) && AND ( PurchaseOrderTransactions[DeliveryDate] >= EARLIER ( PurchaseAgreement[StartDate] ), PurchaseOrderTransactions[DeliveryDate] <= EARLIER ( PurchaseAgreement[EndDate] ) ) ) )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
3 years agoNot applicable
Hi hasanhilmi ,
As far as I know, you don't need to create relationships between two tables. Here we use Table1[Column1] = EARLIER(Table2[Column2]) as condition in our code. So we don't need relationship in data model.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hasanhilmi
3 years agoFrequent Visitor
Yup this worked! Great solution!