Search code examples
google-sheets

DSUM is adding up previous rows to new row


So I have 'Orders' that simplified for this example look like this

OId Total
1
2

I also have 'Line Items' sheet that look like this

IId OId Total
1 1 10
2 1 20
3 2 12
4 2 10

Now I'm trying to use DSUM on Orders sheet to sum up Total value of Line Items per order

I expect to get this:

OId Total
1 30
2 22

What I get is this:

OId Total
1 30
2 52

The formula on Order sheet in column Total I'm using is =DSUM('Line items'!A:B, 'Total', $A$1:A2)

Why am I getting sum of previous rows instead of just ones filtered by the Order Id?


Solution

  • You may try:

    =DSUM('Line items'!A:C, "Total",{"OId";E1})
    

    enter image description here