Using FILTER/UNIQUE on text, numbers

danhendo888

Board Regular
Joined
Jul 15, 2019
Messages
153
Office Version
  1. 365
Platform
  1. Windows
I download the below spreadsheet daily from our software. It shows details of invoices paid/booked.
*It doesn't show it below but the first three columns have the little green ribbon on the top left corner of the cell and is aligned to the left of the cell and has General formatting.

Company NumberInvoice NumberOrder NumberOrder DateOrder TaxOrder SubtotalCurrencyPayment Date
1111111111ABC123 y81900901203/12/202410.00100.00AUD
1111111111ABC123 y81900901203/12/202450.00500.00AUD
1111111111ABC123 y81900901203/12/20240.000.00AUD3/14/2024
1111111111ABC123 y81900901203/12/20240.000.00AUD3/14/2024
222222222211122200081900900001/1/20240.0010,000.00AUD


Below is my own spreadsheet. I type in the invoice number and retrieve the Order Number, Order Total, and Payment Date from the downloaded file.
The first column has the little green ribbon at the top left corner also.
The last three columns is the output I wish to achieve
Company NumberInvoice NumberOrder NumberOrder TotalPayment Date
1111111111ABC12381900901206603/14/2024
2222222222111222000819009000010,000.00


Order Number:
To retrieve the Order Number, I use FILTER and UNIQUE. It retrieves it successfully when the invoice number in my spreadsheet has text formatting e.g. ABC123
But it doesn't work when the invoice number in my spreadsheet has number formatting because the invoice numbers in the downloaded file does not have number formatting. How can I make the formula work for both text and numbers.

Also, how can I retrieve the correct order number when the correct invoice number is "ABC123" but it was incorrectly booked as "ABC123 y"

Order Total:
I use two SUMIFS to add the Order Tax and Order Subtotal columns together.
Is there a more efficient way to add these? Or is this okay to use.

Payment Date:
How can I retrieve the payment date for invoice ABC123? The date does not necessarily show in all rows in the extracted data
 
Is it true that when you filter using Company Number and Invoice Number that you will obtain multiple entries from the Daily sheet, and...
  1. all of those entries will have the same Order Number, and
  2. the Payment Date for that subset of entries will either be blank or share the same date?
Hi Kirk, thank you very much for your help, I appreciate it 🙏
  1. all of those entries will have the same Order Number --> Some invoice numbers will have multiple/different Order Numbers
  2. the Payment Date for that subset of entries will either be blank or share the same date? Yes, correct. The Max formula will work great.

For invoice numbers which have multiple Order Numbers, what would you change in your formula?
 
Upvote 0
I wanted to caution you about something with the ISNUMBER(SEARCH feature. It can cause false positives when the 1st argument of SEARCH (find_text) is blank...then it returns a match nearly everywhere. I realized this when I tried reworking the formula a bit to use the Payment Date method shown by @JEC...the double reciprocal is a clever way to force an error when no date is present, yet return the date when one is. That formula too would be vulnerable to this same issue. If you'll never need to worry about a blank Invoice Number in your worksheet, then this isn't an issue. If you might have a blank, then another error trap is probably needed. Also, I must not have read the initial problem clearly, as I also included Company Name in the filter. That may not be an issue either, as the Company Name and Invoice Number may always be a 1:1 relationship. But if an invoice number is associated with more than one company, then that is an issue.
To clean up the formula, and condense it further, and borrowing the payment date idea from @JEC something like this will handle the blank Invoice Number...which intentionally throws an error result that is later converted to "not found":
MrExcel_20240315.xlsx
ABCDE
1Company NumberInvoice NumberOrder NumberOrder TotalPayment Date
21111111111ABC1238190090120660.003/14/2024
32222222222111222000819009000010,000.00none
4333not found
MyOwnWkSht
Cell Formulas
RangeFormula
C4,C2:E3C2=LET(d,Daily!$A$2:$H$7,f,IF(B2="",#N/A,FILTER(d,ISNUMBER(SEARCH(B2,INDEX(d,,2))))),IFERROR(HSTACK(INDEX(f,1,3),SUM(CHOOSECOLS(f,5,6)),IFERROR(1/(1/MAX(TAKE(f,,-1))),"none")),"not found"))
Dynamic array formulas.

For invoice numbers which have multiple Order Numbers, what would you change in your formula?
What do you want to do with multiple order numbers? Right now, you enter just the Invoice Number and extract all data that matches it. Do you want subtotals for each of the unique order numbers in that subset? Or are you saying that you'd like to initially filter on both the Invoice Number and an inputted Order Number?
 
Last edited:
Upvote 0
Daily
Company NumberInvoice NumberOrder NumberOrder TaxOrder SubtotalPayment Date
1111111111DEF789777777777722212/12/2024
1111111111ABC123 z888888888850500
1111111111ABC123 y999999999910010003/14/2024
2222222222ZZZZZZAAAAAAAAA110
MyOwn(start)
Company NumberInvoice NumberOrder NumberOrder TotalPayment Date
1111111111DEF789
1111111111ABC123
2222222222ZZZZZZ
MyOwn(end)
Company NumberInvoice NumberCount of Order NumbersOrder NumberOrder TotalPayment Date
1111111111DEF789177777777772412/12/2024
1111111111ABC12328888888888550
999999999911003/14/2024
2222222222ZZZZZZ1AAAAAAAAA11


Yes, the same output for each order number.

Since some invoice numbers can have multiple order numbers, I'm not sure how best to achieve the desired output.
Where there are multiple order numbers, since the results will spill but cannot spill if there is data in the rows below, perhaps I should insert a new column notifying me of the count of order numbers? So I can manually insert new rows for the formula to spill? Not sure though

Noted on the revised formula regarding the ISNUMBER feature, thank you.
 
Upvote 0
I agree about the spill issue. There are a few options. You could do a count as you've suggested, which tells you to dig deeper. You could spill sets of results horizontally...a set for each order number. Or you could abandon reporting on the table structure defined by your inputted Invoice Numbers and create an entirely new results table that spills down, shifting lower result blocks so that that don't interfere with those above...I think that's doable, but more complicated. Do you have a preference?

Tell me about the order 888... result line. The Payment Date is blank? So that's an extension of the same idea. The filtered data set would be based on a unique order number and a, perhaps, common invoice number. ...and the order total and payment date would be reflect only those items.
 
Upvote 0
I agree about the spill issue. There are a few options. You could do a count as you've suggested, which tells you to dig deeper. You could spill sets of results horizontally...a set for each order number. Or you could abandon reporting on the table structure defined by your inputted Invoice Numbers and create an entirely new results table that spills down, shifting lower result blocks so that that don't interfere with those above...I think that's doable, but more complicated. Do you have a preference?

Tell me about the order 888... result line. The Payment Date is blank? So that's an extension of the same idea. The filtered data set would be based on a unique order number and a, perhaps, common invoice number. ...and the order total and payment date would be reflect only those items.

I don't have a preference on the spill ideas. I am happy to apply any method.

Regarding invoice number ABC123.
Our supplier sends us this invoice and I would enter the invoice into the accounting software. We can book the whole amount of the invoice once (i.e. 1 x Order Number for 1 x invoice)
Or we can book half of it now, half of it later (2 x Order Numbers for 1 x invoice).

And that's why the payment date exists for one order number but not another. Because they can be paid at separate times.
 
Upvote 0
Works beautifully, thank you.

Can it also be spilled horizontally like the below? (Ignoring all other issues)

Company NumberInvoice NumberOrder NumberOrder TotalPayment Date
1111111111ABC12381900901201103/13/2024
8190090144153/14/2024
 
Upvote 0
Much appreciated Kirk!
I am learning so much from your posts, thank you

And sincere apologies for not including all the necessary information in the OP :cry:
 
Upvote 0
You're welcome...I'm happy to help. I don't quite have the same error trapping in the vertical spilling versions, but I'm not sure if that is a problem either. Have a look and let me know if you encounter any problems or have any questions about the formula. One thing I noted is that a blank invoice number on the input side produces an error, but the cause is fairly obvious as there is nothing to lookup.
 
Upvote 0
intres, BYROW(m, LAMBDA(r, LET(cn, INDEX(r, 1), in, INDEX(r, 2)

Regarding Option 2 in cell Y2, specifically the part above.
It looks like it's defining cn and in within m but m is the below (correct?):

1111111111ABC123
111222000
3333333333111552000
11144000


Why is the INDEX (r,1) and (r,2) targeting the rows? And not the columns?
 
Upvote 0
Also, is it possible to search not just for the invoice number but by company number AND the invoice number (for instances where the same invoice number is issued by two different companies?
I tried adding INDEX(d,,1)=cn* to f but it's not quite right
 
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,008
Members
449,480
Latest member
yesitisasport

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