# Join quantity of matched records?

**URL:** <https://community.parabola.io/t/join-quantity-of-matched-records/1151>\
**Category:** Ask a question\
**Created:** [October 7, 2020, 8:46pm UTC](https://community.parabola.io/t/join-quantity-of-matched-records/1151 "2020-10-07T20:46:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julie\_Taylor](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@Julie\_Taylor](https://community.parabola.io/u/Julie_Taylor)\
**Post date:** [October 7, 2020, 8:46pm UTC](https://community.parabola.io/t/join-quantity-of-matched-records/1151/1 "2020-10-07T20:46:34Z")

</div>

I have two tables: Primary table called Payments and secondary table called Invoices.

**Payment Table fields**

- Customer number
- Amount  
**- [Customer number] [Amount] _concatenated_**

**Invoice Table fields**

- Customer number
- Amount
- Invoice number
- **[Customer number] [Amount] _concatenated_**

I may have 3 payments for a given customer that I need to match to an invoice number; however, there may be 5 invoices. I want to look up 3 of the 5 invoices to find the corresponding invoice number.

My problem is that when I combine tables, I get all 5 invoices because they all match my primary key ([customer number] [amount] _concatenated_).

Is there a way I can tell Parabola, if I have 3 records in one table, do not find more than 3 matches in the corresponding second table?

This is driving me nuts!

Thank you for any help you can provide!!

---

<div class="post-metadata">

**Author:** ![sachi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.parabola.io/sachi/32/10_2.png) [@sachi](https://community.parabola.io/u/sachi)\
**Post date:** [October 7, 2020, 9:17pm UTC](https://community.parabola.io/t/join-quantity-of-matched-records/1151/2 "2020-10-07T21:17:28Z")

</div>

Hey @Julie_Taylor !

Thanks for posting your question. I think I follow. For the invoice table, where you might have a few invoice numbers for a given `([customer number] [amount] *concatenated* )`, how should we determine which `invoice number` to match? Are you considering `([customer number] [amount] concatenated)` values to be unique?

Depending on what you need, one option might be to use a `Remove duplicate rows` step before the `Combine tables` step to make sure you only have 1 invoice number per `([customer number] [amount] concatenated)` value. This will ensure that we only append 1 invoice number when using the `Combine tables` step.

Would that work?

---

<div class="post-metadata">

**Author:** ![Julie\_Taylor](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@Julie\_Taylor](https://community.parabola.io/u/Julie_Taylor)\
**Post date:** [October 8, 2020, 2:19pm UTC](https://community.parabola.io/t/join-quantity-of-matched-records/1151/3 "2020-10-08T14:19:03Z")

</div>

We have a lot of payments from the same customer on the same date for the same amount. Our payment file (unfortunately) does not contain an invoice number. So we concatenate the customer and the amount to reduce the number of possible matches.

So our payment file might have 3 $5 payments:  
ID-customerABC-5  
ID-customerABC-5  
ID-customerABC-5

We need to match it to our open invoices file which might have 4 $5 open invoices:  
ID-customerABC-5  
ID-customerABC-5  
ID-customerABC-5  
ID-customerABC-5

I need to apply the 3 payments to 3 of the invoices and leave one invoice unmatched.

Does that make sense?

---

<div class="post-metadata">

**Author:** ![sachi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.parabola.io/sachi/32/10_2.png) [@sachi](https://community.parabola.io/u/sachi)\
**Post date:** [October 8, 2020, 5:49pm UTC](https://community.parabola.io/t/join-quantity-of-matched-records/1151/4 "2020-10-08T17:49:56Z")

</div>

Hey @Julie_Taylor - I created some dummy data to demo what I think you’re trying to accomplish.

Here’s my invoice table:

 ![Screen Shot 2020-10-08 at 10.41.45 AM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/98e49e70fa9565aad7bac9d6491a4e8eadabf746.png)

Here’s my payment table:  
 ![Screen Shot 2020-10-08 at 10.42.56 AM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/c7e6e58ac38e00a699ca28603d1185d7f4bb54bf.png)

Then, I used the `Combine columns` step to create the matching column (concatenating `Customer Number` and `Amount`)

Here’s my updated invoices table:

 ![Screen Shot 2020-10-08 at 10.45.15 AM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/ad386d13537ebd2ef6a21dd11710ad4ba05bfc0e.png)

Here’s my updated payments table:  
 ![Screen Shot 2020-10-08 at 10.45.35 AM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/fa3c24c53b2d2746a29e117dff12119b76e3aa8b.png)

Then I used the `Combine Tables` step where the `Invoices `table is actually my primary table. I set it up like this where `Invoices` is my primary table and I select to `Keep all rows in all tables.`

You’ll see that `Matching column (1)` gets appended for the invoice/payment matches and that fourth invoice is unmatched.

 ![Screen Shot 2020-10-08 at 10.47.58 AM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/5bb4b176b36610c7e26d37bdcfa1376bb2a7eed9.png)

Did I understand your data and your goals correctly? If not, clarify for me and I can readjust!

---

<div class="post-metadata">

**Author:** ![Julie\_Taylor](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@Julie\_Taylor](https://community.parabola.io/u/Julie_Taylor)\
**Post date:** [October 8, 2020, 5:57pm UTC](https://community.parabola.io/t/join-quantity-of-matched-records/1151/5 "2020-10-08T17:57:06Z")

</div>

You have the general idea and are almost right.

In your customer column you have Cust 1, Cust 2, Cust 3. But I may get 3 payments from Customer 1, all of them $5.

In the other table, I have 4 open invoices for Customer 1… all of them also $5.

---

<div class="post-metadata">

**Author:** ![sachi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.parabola.io/sachi/32/10_2.png) [@sachi](https://community.parabola.io/u/sachi)\
**Post date:** [October 9, 2020, 2:04am UTC](https://community.parabola.io/t/join-quantity-of-matched-records/1151/6 "2020-10-09T02:04:36Z")

</div>

Got it. This does make it more complicated, but is do-able 🙂 Here’s what the flow is going to look like.

 ![Screen Shot 2020-10-08 at 6.58.42 PM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/3937e4bef4f359d33d302e26d9381f4f0f706659.png)

Essentially, for both the Invoices table and the Payments table, we need to create a counter column that counts for each unique customer-amount combination, how many invoices there are and how many payments there are. That’s what all the steps in the two branches you see in my screenshot are doing. Once we have that, we can combine that tables and do some final cleanup. The end result of this flow looks like this:

 ![Screen Shot 2020-10-08 at 7.01.09 PM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/9d4285ce04e5285514df6ae739597f1479fe2e37.png)  
`Amount owed` is the invoices column and `Amount paid` is the payments column.

Here’s a snippet you can copy and paste (using your keyboard shortcuts) to paste a copy of these steps onto your own flow: **parabola:cb:b9ef72fa51974911be0e9685cd96eb3f**

You can click into each of the steps to see what they’re doing. Hope that helps!

---

<div class="post-metadata">

**Author:** ![Julie\_Taylor](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@Julie\_Taylor](https://community.parabola.io/u/Julie_Taylor)\
**Post date:** [October 13, 2020, 2:07pm UTC](https://community.parabola.io/t/join-quantity-of-matched-records/1151/7 "2020-10-13T14:07:39Z")

</div>

It worked!! I’m so excited; thank you for solving that. I NEVER would have been able to figure out that path to creating sequential numbers. Pure genius! 😃

Thank you, thank you!
