Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
dimak123
Partner - Contributor III
Partner - Contributor III

Count Quantity for invoice

Good day,

need some help with aggregations:

I want to show a list of clients and to see how many invoices(just count) contained only one item, 2 items, 3 items and 4 according to quantity field.

this is my data:

  

CustomerIdInvoiceIdInvoiceLineItemIdQuantity
10023701390082_INV1106920162
10023701390082_INV2106920161
10023701390083_INV3106920162
10023701390083_INV6106920162
10023701390084_INV7106920162
10023701390084_INV8106920162
10008301390090_INV1102810044
10008301390090_INV2106920161
10008301390091_INV3102810042
10008301390091_INV4102810042
10008301390092_INV5102810041
10008301390092_INV6102810044
10008301390093_INV7102810044
10023701390089_INV1106920161

this what i am trying to get:

      

CustomerId1 item for Invoice2 items for Invoice3 items for Invoice4 items for Invoice5 and more
1002371 12
100083 22

thanks a head

11 Replies
swuehl
MVP
MVP

You need to aggregate per invoice, so 01390082_INV has two lines, sum of quantity is (2+1)=3.

dimak123
Partner - Contributor III
Partner - Contributor III
Author

Customer 100237 had 4 invoices (sum the lines by invoice):

  1. 01390082_INV - have 3 in quantity
  2. 01390083_INV - have 4 in quantity
  3. 01390084_INV - have 4 in quantity
  4. 01390089_INV - have  1 in quantity