How to return multiple unique invoice numbers of a sales order

ameenuksg

Board Regular
Joined
Jul 11, 2017
Messages
83
Hi All - I tried using index match to return matching results for sales order# 133213 which is duplicated in the row below in Sheet 1, Column A. But it always returns only the first invoice# it could find on Sheet 2, Column A for both rows in Sheet 1, Column F. Appreciate any help, and thank you so much in advance ?
Column AColumn FColumn AColumn E
Sales Order#Invoice#Invoice#Sales Order#
1332136700000456133213
1332136700000443133213
1213236700000478121323
Sheet 1Sheet 1Sheet 2Sheet 2
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi Ameenuksg,

You'll need to use SMALL to find the first, then second, etc. or use the SMALL option of AGGREGATE (16) as I've done in my example.

Data in Sheet2
Book1
ABCDE
1Invoice#Sales Order#
26700000456133213
36700000443133213
46700000478121323
Sheet2


Here's the formulae in Sheet1

Ameenuksg.xlsx
ABCDEF
1Sales Order#Invoice#
21332136700000456
31332136700000443
41213236700000478
Sheet1
Cell Formulas
RangeFormula
F2:F4F2=INDEX(Sheet2!$A$2:$A$999,AGGREGATE(15,6,ROW(Sheet2!$E$2:$E$999)-1/(A2=Sheet2!$E$2:$E$999),COUNTIF($A$2:$A2,A2)))


You'll get a #NUM error if there's no match or second match but you can wrap an IFERROR around to trap.
 
Upvote 0
Hi Thank you so much for your help, I tried your formula but it seems to return a result from a cell 2 rows after although there is only 1 result for this match.

Here is the formula I had incorporated from yours:
=IFERROR(INDEX(SalesWotherView[Billing document],AGGREGATE(15,6,ROW(SalesWotherView[Sales Order])-1/([@[SO'#]]=SalesWotherView[Sales Order]),COUNTIF($E$274:$E274,E274))),"no invoice")
 
Upvote 0
Here are pictures of the actual sheets.

Sheet 1 = 'Orders'
Sheet 2 = 'Sales w other view'
 

Attachments

  • Sheet 1 resized.JPG
    Sheet 1 resized.JPG
    86.8 KB · Views: 13
  • Sheet 2 resized.JPG
    Sheet 2 resized.JPG
    79.1 KB · Views: 13
Upvote 0
It's because your headings are on row 3 and not row 1. I'm not going to retype all the data so let me try and duplicate with my small dataset:

Sheet2 data
Ameenuksg-v2.xlsx
ABCDE
1
2
3Billing DocumentBCDSales Order#
46700000456133213
56700000443133213
66700000478121323
Sheet2


Sheet1 formula

Ameenuksg-v2.xlsx
ABCDEFGHIJKLMNO
1Account#BCDSO#FGInvoice#IJKLMNInvoice#2
283838382277881332138888886700000456
392929293366991332139999996700000443
4454537244551111213231111111116700000478
Sheet1
Cell Formulas
RangeFormula
O2:O4O2=INDEX(Billing_Document,AGGREGATE(15,6,ROW(Sales_Order)-ROW(Table1[[#Headers],[Sales Order'#]])/([@[SO'#]]=Sales_Order),COUNTIF($E$2:$E2,[@[SO'#]])))
Named Ranges
NameRefers ToCells
Billing_Document=Sheet2!$A$4:$A$6O2:O4
Sales_Order=Sheet2!$E$4:$E$6O2:O4


If you install XL2BB it would be easier to see your data and Named Ranges.
 
Upvote 0
=INDEX(SalesWotherView[Billing document],AGGREGATE(15,6,ROW(SalesWotherView[Sales Order])-ROW(SalesWotherView[#Headers],[SO'#])/([@[SO'#]]=SalesWotherView[Sales Order]),COUNTIF($E$274:$E274,[@[SO'#]])))

I don't know whats wrong with the above formula that I typed in, but it shades the above part of the code shown in red and says that I have entered too many arguments for this function?
 
Upvote 0
I can't see how you've named your tables/columns but because you're starting your headings on row 3 you could just replace
-ROW(SalesWotherView[#Headers],[SO'#])
with
-3
 
Upvote 0
Got it, I think I didnt understand how row function worked so now I know after removing '[SO'#]' from the row function and left it with '-ROW(SalesWotherView[#Headers])' only and its working wonders now. Cant thank you enough for putting the time and effort to help me?
 
Upvote 0
Hi - What if I want to look up sales order# of another table too, so how do I improve on the formula above.
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,566
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top