Excel - Index and match many to many results vertically - arrays

in excel document, I have in sheet "Documents" reference nr. with corresponding values, for example:
Column A
Column B
Reference
Document
12345
Document1
12345
Document2
12345
Document3
54321
Contract1
54321
Contract2
In sheet "Main", I have the following
Column A
Column B
Column C
Reference
Document
12345
12345
12345
12345
12345
12345
12345
12345
12345
I would need result from sheet "Documents" from column B in column C of sheet "Main". In sheet "Main" there are always 9 reference numbers (for each) reference) but in sheet "Documents" reference nr. varies from 2 to 8. So, for these reference nr.in sheet "Main" which are excessive, I would need some kind of different result, for example #N/A or similar...
I have tried with array formulas with no success.
Help would be appricated...
Many thanks

Give a try to-
=MAP(A2:A10,LAMBDA(x,IFERROR(INDEX(FILTER(Documents!B:B,Documents!A:A=x),ROW(x)-ROW($A$1)),"Your Message")))

Related

Is there a function or a solution to source from different sheet (and file) based on criteria? WITHOUT VBA

What I am basicaly looking for is a way to lookup data from 1 sheet/file named "Sheet 2021" in case the part of lookup value is "XYZ/21" and for it to look in "Sheet 2022" from another file in case the lookup value is "XYZ/22" In addition to that it needs to have multiple criteria as the 2nd lookup value is a 10 digit code.
Example:
I have sheet called "Claims 2022" and Sheet called "Claims 2021"
Listed values in 1st (RMA 2021):
RMA
Date of issue
Item Number
Finished?
28/20
2/5/2020
1234567890
Yes
1/21
3/6/2021
1234567890
No
1/21
3/6/2021
0987654321
Yes
1/21
3/6/2021
1111111111
No
1/22
1/1/2022
2222222222
Yes
Listed values in 2nd (RMA 2022):
RMA
Date of issue
Item Number
Finished?
14/21
11/12/2021
1234567890
Yes
2/22
3/7/2022
1234567890
No
20/22
3/6/2022
0987654321
Yes
20/22
3/6/2022
1111111111
No
22/22
4/8/2022
2222222222
No
I want to:
extract these in a single file based on the date (If it is issued in 2021).
And then extract the value for "Finished".
The reason that numbers do not match the year is because the supply chain program lists them out based on the date of arrival. And I cannot influence or add anything to the source excel.
I don't want a brute force solution such as "if date 21 then 21" through a helper column as the file is gonna expand with other years.
Perhaps there is a function or a possibility to change the source depending on value?
For example:
[Source.xlsx]RMA `<value>`'!$C$3:$C$150
Where <value> would change based on 2020,2021,2022...
Or perhaps there is a more intuitive solution?

Counting grouped cells excel

Currently I have a excel table that looks like this
A B C D E F G
ID NAME DATE ITEM 2020 3
1234 Alex 09-20-2020 Carrot 2019 2
1234 Alex 09-20-2020 Onion
1234 Alex 09-20-2019 Carrot
1234 Alex 09-20-2019 Mushroom
1234 Alex 09-20-2020 Pasta
1345 Morgan 09-20-2020 Pasta
1345 Morgan 09-20-2020 Tomato Sauce
1145 Jayson 09-20-2020 Tomato Sauce
1145 Jayson 09-20-2020 Cream Sauce
1345 Morgan 09-20-2019 Pasta
1345 Morgan 09-20-2019 Tomato Sauce
I want to be able to count the unique customers for each year using excel functions. This is so that the functions can be transferred to a different computers without setting up the custom functions.
The proccess currently can be done in excel without function by: adding filter to each column, filtering to only show the intended year, using remove duplicate to remove duplicates in NAME, and finally counting the rows (giving reslts seen in G2 & G3). However, I want to be able to do that through excel functions. So far what I have is that I am able to count unique values through
{=SUM(IF(FREQUENCY(IF(LEN(B2:B12)>0,MATCH(B2:B12,B2:B12,0),""),IF(LEN(B2:B12)>0,MATCH(B2:B12,B2:B12,0),''))>0,1))}
Additionally I am also able to SUMPRODUCT() for counting a array with multiple condition so for now I have combined the above forumla with
SUMPRODUCT((YEAR(C2:C12)=G1)+0)
My initial idea was to add the first function into the SUMPRODUCTI() since the first function could also produce a array that it could count. However that quickly did not work as it did not count the unique values corresponding to the year.
My question here is if there is any way to what would be a grouping function so that I can take unique values that are within a year, without transforming the data (through filters of deletion of duplicates). My current understanding with SUMPRODUCT() is that it will only look for unique values in the entire column but not within the range given for the first array.
You have got numeric ID's which you should make use of. If you have got Excel O365, in G1 use:
=COUNT(UNQIUE(FILTER(A$2:A$12,YEAR(C$2:C$12)=F1)))
With older versions, use this CSE-entered formula:
=SUM(--(FREQUENCY(IF(YEAR(C$2:C$12)=F1,A$2:A$12),A$2:A$12)>0))
And drag down.

If statement across MS Excel sheets

BACKGROUND (simplified version): I’m sorting data sheets of different items for our lab. I have one sheet that lists the code number of the item (column A) with the actual name of the item (column B), for example
code | item
001 | Banana
002 | Cabbage
003 | Carrot
004 | Peach
and another sheet (labelled stocks) that lists only the code number (column A) and the amount of stock we have for that item (column B), for example
code | stock
001 | 5
002 | 6
003 | 2
004 | 7
PROBLEM: Now, these items can be sorted into 2 categories, “fruits” and “vegetables”. I can easily sort the items in the item sheet manually because I can see the actual item name, but for the stock sheet, only the code number is listed which means I would have to keep looking at the other sheet to see which item is associated with a particular code.
I already have separate item sheets for fruits and vegetables, so I have three sheets total now: fruits, vegetables, and stocks.
I was thinking of an IF statement to be placed in the stocks sheet that would indicate if the item is a fruit or a vegetable. Something like: if the code in A1 of the “stocks” sheet is present in column A of the “fruit” sheet, then print the word “fruit” in C1 of the “stocks” sheet. If not, print the word “vegetable” in C1.
My ultimate goal (what the lab is looking for) is that I would have separate item sheets for fruits and vegetables (already done) and also separate stock sheets for fruits and vegetables (to be done).
Would appreciate any help. Many thanks
VLOOKUP works well for this.
Make a third column in the stock sheet with the following formula in Cell C2 and copy it down to the cells below:
=VLOOKUP(A2,Fruits!$A$2:$B$200,2,FALSE)
This takes the value in cell A2, find the same id in the table in sheet 1 and returns the value that is given in the 2nd column of the Fruit Worksheet.
If you want the tables fruits and vegetables separate. You can use IFNA to find the id in the second worksheet as followed:
=IFNA(VLOOKUP(A2,Fruits!$A$2:$B$200,2,FALSE),VLOOKUP(A2,Vegetables!$A$2:$B$200,2,FALSE))
if the code in A1 of the “stocks” sheet is present in column A of the “fruit” sheet, then print the word “fruit” in C1 of the “stocks” sheet. If not, print the word “vegetable” in C1.
This is a simple test across the worksheet. This formula searches range A:A in the "Fruit" sheet, and if there is a match (returned as a number) it gives the first value "Fruit", otherwise it will return "Vegetable".
=IF(ISNUMBER(MATCH(A1,Fruit!A:A,0)),"Fruit","Vegetable")
However be careful with this, because if the code is wrong of not found, it will return "vegetable" by default. To get around this, use a nested IF statement which checks both sheets like so, and returns "Not found" if the code is wrong.
=IF(ISNUMBER(MATCH(A1,Fruit!A:A,0)),"Fruit",IF(ISNUMBER(MATCH(A1,Vegetable!A:A,0)),"Vegetable","Not found"))
EDIT: I've swapped the SEARCH for the more powerful MATCH since this will negate display options and still find the correct sheet.

Looking to count the number of times a company name appears in a column, while excluding a duplicate value in another column

Spreadsheet column setup:
A:Name B:Hours C:Client D:Invoice# E:Date
Joe 8 Acme 123 8/21/18
Bill 12 Zorg 456 8/19/18
John 9 Acme 123 8/21/18
Ben 15 Acme 987 8/5/18
I want to count the number of jobs we did for a client for the month.
Each individual job is denoted by the invoice number. A job may have multiple people on it so the same invoice number will be duplicated in column D.
I'd like exclude those duplicates so I get a true count of jobs for a particular client regardless of how many people were actually on the job.
Using the example above, if I ask for total number of "Acme" jobs this month, I need the output to read 2 (since invoice 123 had a couple guys on it) not 3 due to it not excluding the duplicate invoice number.
Nothing I try or search on the internet like function CountIf quite meets my unique parameters.
Please advise, Thank you.

excel assemble two sheets exported from database

I have two sheet of excel exported from a database with hundreds of rows.
In first sheet I've these columns
name age gender
id1 23 m
id2 45 f
In second sheet these columns
id1 john smith
id2 jean ford
I'm looking for a macro or somethig else to automatically replace the idx in first sheet with the corresponding values from second sheet.
The final result should be a sheet like:
name age gender
john smith 23 m
jean ford 45 f
You don't need anything as complicated as a macro-- VLOOKUP will suffice:
Searches for a value in the first column of a table array and returns
a value in the same row from another column in the table array.
The V in VLOOKUP stands for vertical. Use VLOOKUP instead of HLOOKUP
when your comparison values are located in a column to the left of the
data that you want to find.
For example, if your id-sheet mapping was on Sheet2, then the formula
=VLOOKUP(A2,Sheet2.$A$1:$B$2, 2)
would look for the value found in this sheet's A2 cell in the leftmost column of the data table located in Sheet2.$A$1:$B$2, and then return the value from the 2nd column of that table. Copy that downwards, and get something like

Resources