Returning all values that meet one criterion

Velvet Dan

New Member
Joined
Oct 28, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to look up and return all invoice #'s that were paid in the year 2021. The invoice #'s and year paid are two separate columns. I would like to return all the applicable invoice #'s in column A in another sheet. I have attempted the problem myself using the INDEX function but it only returns the first matching value. Below is the current formula I'm using. I'm using tables so you will notice I have table references instead of ranges.

Excel Formula:
=INDEX(InvoiceTable[Invoice '#],MATCH(0,IF(InvoiceTable[Year Paid] = 2021, COUNTIF(InvoiceTable[@[Year Paid]],InvoiceTable[Invoice '#]), ""),0))

Thank you in advance!

Sincerely,

Dan
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi & welcome to MrExcel.
As long as you are not putting the formula into a table, try
Excel Formula:
=filter(InvoiceTable[Invoice '#],InvoiceTable[Year Paid] = 2021)
 
Upvote 0
Hi & welcome to MrExcel.
As long as you are not putting the formula into a table, try
Excel Formula:
=filter(InvoiceTable[Invoice '#],InvoiceTable[Year Paid] = 2021)
Darn, unfortunately, I do need to put it into a table. This will be useful in the future though, thank you. Is there anything else I can try?
 
Upvote 0
How about
Excel Formula:
=INDEX(InvoiceTable[Invoice '#],AGGREGATE(15,6,(ROW(InvoiceTable[Invoice '#])-ROW(InvoiceTable[#Headers]))/(InvoiceTable[Year Paid]=2021),ROWS(S$9:S9)))
Change the S$9:S9 at the end to reflect the 1st cell that the formula is in.
 
Upvote 0
How about
Excel Formula:
=INDEX(InvoiceTable[Invoice '#],AGGREGATE(15,6,(ROW(InvoiceTable[Invoice '#])-ROW(InvoiceTable[#Headers]))/(InvoiceTable[Year Paid]=2021),ROWS(S$9:S9)))
Change the S$9:S9 at the end to reflect the 1st cell that the formula is in.
Thank you again for the reply. I tried this and the function only displays the first matching invoice # instead of all of the invoice #'s. Any idea why that is?
 
Upvote 0
Did you drag the formula down as far as needed?
 
Upvote 0
Did you drag the formula down as far as needed?
I just tried it and it populates all the cells with the same invoice #, the first match. I’m not sure why it’s not displaying unique records.
 
Upvote 0
If you want distinct numbers use
Excel Formula:
=INDEX(InvoiceTable[Invoice '#],AGGREGATE(15,6,(ROW(InvoiceTable[Invoice '#])-ROW(InvoiceTable[#Headers]))/(InvoiceTable[Year Paid]=2021)/(ISNA(MATCH(InvoiceTable[Invoice '#],S$8:S8,0))),1))
Change the S$8:S8 to refer to the directly above where you put the formula
 
Upvote 0
If you're putting a formula in a table, you can't drag it down. The identical formula is replicated in each row. But you can do something like this:

Book1
ABCDEF
1Something2021 InvoicesInvoice #Year Paid
2a312020
3b422020
4c632021
5d742021
6e 52022
7f 62021
8g 72021
9h 
10
Sheet3
Cell Formulas
RangeFormula
B2:B9B2=IFERROR(INDEX(FILTER(InvoiceTable[Invoice '#],InvoiceTable[Year Paid]=2021),ROW([@[2021 Invoices]])-ROW(Table2[#Headers])),"")
 
Upvote 0
Solution
If you want distinct numbers use
Excel Formula:
=INDEX(InvoiceTable[Invoice '#],AGGREGATE(15,6,(ROW(InvoiceTable[Invoice '#])-ROW(InvoiceTable[#Headers]))/(InvoiceTable[Year Paid]=2021)/(ISNA(MATCH(InvoiceTable[Invoice '#],S$8:S8,0))),1))
Change the S$8:S8 to refer to the directly above where you put the formula
If you're putting a formula in a table, you can't drag it down. The identical formula is replicated in each row. But you can do something like this:

Book1
ABCDEF
1Something2021 InvoicesInvoice #Year Paid
2a312020
3b422020
4c632021
5d742021
6e 52022
7f 62021
8g 72021
9h 
10
Sheet3
Cell Formulas
RangeFormula
B2:B9B2=IFERROR(INDEX(FILTER(InvoiceTable[Invoice '#],InvoiceTable[Year Paid]=2021),ROW([@[2021 Invoices]])-ROW(Table2[#Headers])),"")
This worked, thank you both so much for your help!
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,872
Members
449,097
Latest member
dbomb1414

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