Lookup Value with multiple outcomes - No Array Formula - excel

I am creating a spreadsheet that a LARGE amount of people are going to use that have no experience with Excel...
What I want to have happen is they scan an order number into a field and it will populate the information on all lines of their order. When they scan, the scanner only populates the first 8 digits on the order, and it does not pick up on how many lines are on the data.
So for example; The scanner will return FK560082 but the data from the system will say FK560082.001.8051 and if there are multiple lines on the order it will have FK560082.002.8051 and etc... (We have no limit on the number of lines allowed an order).
Right now, I used the formula below to break the order number away from the other details.
=IFERROR(LEFT(A2,FIND(".",A2,1)-1),A2)
Which allowed me to use this formula to get my first occurrence (or first line) of my order. However, I'm looking for a formula that will allow me to find data from my other line items too.
=IFERROR(INDEX('Current Orders'!F:F,MATCH('2'!A2,'Current Orders'!L:L,0)),"")
Since so many people are going to use this spreadsheet, I'd prefer to not have to train everyone on the ctrl+shift+enter of an array formula, but if that's all that's possible I'll make it work.

One or more FK560082.002.8051 values in 'Current Orders'!L:L. FK560082 in 2!A2. Additional information to be retrieved from 'Current Orders'!F:F.
Try,
=iferror(index('Current Orders'!F:F, aggregate(15, 6, row('Current Orders'!L$1:index('Current Orders'!L:L, match("zzz", 'Current Orders'!L:L)))/(left('Current Orders'!L$1:index('Current Orders'!L:L, match("zzz", 'Current Orders'!L:L)), len('2'!A$2))='2'!A$2), row(1:1))), text(,))
Drag down for subsequent invoice lines.

I think this can be done using INDIRECT and by searching through Current Orders beginning after the first line that was found.
These search result formulas can be used on sheet '2' or any other sheet.
Separate your search results into two columns: the result, and a column for the row that was found. I'll use B. First item on the order, cell B4 formula is =MATCH('2'!$A$2,'Current Orders'!L:L,0)
Second item in column B (cell B5) will be =IFERROR(MATCH('2'!$A$2, INDIRECT("'Current Orders'!L" & $B4 & ":L9999"),0),""). Fill down from cell B5.
Column A will be the actual value, for instance at A4 =IFERROR(INDEX('Current Orders'!F:F, $B4),""). Fill down from A4 onward.
Good luck!

Does this answer you question?
[https://stackoverflow.com/a/18767728/9492960][1]
=INDEX('Sheet2'!B:B,MATCH(1,INDEX((A1='Sheet2'!A:A)*(C1='Sheet2'!C:C),0),0))
Is an Index Match with multiple criteria without an array.

Related

How do I display all my results for a specific search. When the specific search has multiples results. Not using vLookup

I have a sheet with 2 columns. ID and SearchTerm
ID has the same ID# for multiple SearchTerms.
I am trying to search for example ID# 25 and then be able to show all results on a separate sheet. Without having to search for the ID number and then Copy and Paste the columb.
I tried doing a vLookup, but it only gives me back the first SearchTerm based on the ID.
For only 7225 rows of data, an array formula isn't too bad, speed-wise (enter it as an array formula with Ctrl+Shift+Enter in a range that is 100 rows long and one column wide):
=INDEX(B1:B7225,SMALL(IF(A1:A7225=4,ROW(A1:A7225)),ROW(INDIRECT("1:100"))))
Change the 4 to the desired search value (or a cell with the desired search value). You can get more/less than 100 results by changing the 100.
I just tested it against a non-array version that you fill down, e.g.,
=INDEX(B1:B7225,AGGREGATE(14,6,ROW(B$1:B$7225)/((A$1:A$7255)=4),ROW(A1)))
and the array version is more than an order of magnitude faster.
Lets assume your search ID in in E4 and you want your search results to be in F4:F21. In F4 place the following formula and copy it down the maximum number row you think you might have.
=INDEX(B:B,AGGREGATE(14,6,ROW(B$1:B$7225)/((A$1:A$7255)=E4),ROW(A1)))
I was going to put a caveat in about don't use full column references within the AGGREGATE function because it performs array calculations and will slow things down, but I believe Scott Craner's comment covered that.
Having said all that I believe using filters is the faster approach.
UPDATE
In order to avoid errors from being displayed, wrap the whole thing in an IFERROR function:
=IFERROR(INDEX(B:B,AGGREGATE(14,6,ROW(B$1:B$7225)/((A$1:A$7255)=E4),ROW(A1))),"")

Excel - How to count unique days in a list a duplicated days

Having a list of days suchs as:
01-giu-16
01-giu-16
01-giu-16
31-mag-16
31-mag-16
31-mag-16
31-mag-16
30-mag-16
I was looking for an excel formula that helps me count the number of unique days in the list (in this example 3)
Moreover I need the count only for the dates which have a specific ID in the next column (for example 1565)
Without any additional criteria, you can achieve the uniqueness count by using
=SUMPRODUCT(1/COUNTIF(A1:A8,A1:A8)), assuming your data are in the range A1:A8.
To evaluate subject to additional criteria (suppose they are in column B), use
{=SUM(--(FREQUENCY(IF(B1:B8=1565,MATCH(A1:A8,A1:A8,0)),ROW(A1:A8)-ROW(A1)+1)>0))}
This is an array formula: use Ctrl + Shift + Return once you're done editing (and don't type the curly braces yourself). Personally though I think this exceeds the reasonable threshold for complexity: I'd be inclined to adopt the first approach on a column that represents an intermediate transformation of your input data.
Lets assume your data is in Column A and it has a header row. So the first data number will actually be in A2. Place this formula in B2 and copy down beside your list. It will generate a list of unique cell numbers from column A. Once you have the list you simply need to use a function to count the side of it.
=iferror(INDEX($A$2:$A$5,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$5),0,0),0)),"")
in C2 you can use the following formula to get the number of unique cell numbers
=COUNTA(B2:B9)-COUNTIF(B2:B9,"")
In D2 you can use the following formula to get the count of each unique cell number from your original list. Copy it down as far as you need to go.
=IF(B5="","",COUNTIF($A$2:$A$9,B5))

How to tell if a cell exists on another Google Sheet

I have 12 sheets in one Google Sheets document labeled for each month (January - December). On each sheet column A contains a project number, e.g. "6091".
I'm trying to find a function that will check all of the other sheets to see if there are duplicate cells in the "project number" column of other sheets.
So: "Do any of the cells in column A, match any of the cells in column A on other sheets".
Is there a quick way to do this?
The formula =arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0))) checks each value in A2:A of the present sheet for being in A2:A of AnotherSheet. If it's there, it returns the position in AnotherSheet, otherwise the output is empty (the error #N/A is suppressed by iferror).
You can use the above for each of the sheets separately. Alternatively, if you are not interested in the positions and just want to know which entries from A2:A are found elsewhere, then add the results for each sheet:
=arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0)) + iferror(match(A2:A, ThirdSheet!A2:A, 0)))
The output is 0 is there is no match, and a nonzero number if there is.
You may try using this to find the number of duplicates:
=counta('JAN'!A:A,'FEB'!A:A)-countA(unique({'JAN'!A:A;'FEB'!A:A})
Where A:A is your column for the data you want to check and the respective files.
This formula counts the total number of data you have, minus the unique data, therefore giving you the total number of duplicates in your dataset.
This formula gives you an overview of the total number of duplicates, however, it doesn't show which cell is a duplicate.
Alternatively, you can add a checker column and input the following formula to check if that specific cell is a duplicate.
=match(cell to check,{range 1;range 2;...range 12})
Alternatively, you may use this formula to find the exact duplicates between the ranges, however this formula does not search within the range itself for duplicates.
=arrayformula(filter(range to check,(countif(arrayformula({Range 1;range 2}),{range to check}))>1))
Personally I think that the last option would be the best as it gives you the exact data to correct.
I am still new to this so hope this helps:)
This formula should work for numerical values:
=COUNT(QUERY({March!A:A;April!A:A},"where Col1="&A2))
If you are searching for text values it would be
=COUNTA(QUERY({March!A:A;April!A:A},"where Col1='"&A2&"'"))
Unfortunately the QUERY function does not work within an arrayformula so you would need to copy the formula down the column. You can add in extra sheets into the { } array as required, separated by a semi-colon
Edit: actually, borrowing from #sandwich, this version should work without the need to copy the formula down the column:
=arrayformula(iferror(match(A2:A,{March!A:A;April!A:A},0)))

Excel formula to extract multiple matching values [duplicate]

This question already has an answer here:
INDEX and SMALL only returning one result
(1 answer)
Closed 7 years ago.
I'm looking for what I thought would be a pretty straightforward formula to compile a list of names based on a criterion. For example, I would have a list of 50 employee names in column A and then a "Y" or "N" next to each name in column B. I would then like to have another tab on the spreadsheet list the names of everyone with a "Y" value in column B. I dont want empty rows between the names in the list on the new tab (this is why I haven't had success with IF statements). I also would like to avoid manually filtering out blank rows.
Lets say your first sheet is Sheet1
on Sheet 2 on a1 enter:
=IF(ISERROR(INDEX(Sheet1!A:A,MATCH("Y",Sheet1!B:B,0))),"",INDEX(Sheet1!A:A,MATCH("Y",Sheet1!B:B,0)))
On a2 enter:
=IF(ISERROR(INDEX(INDIRECT("Sheet1!A"&MATCH(A1,Sheet1!A:A,0)+1&":A50"),MATCH("Y",INDIRECT("Sheet1!B"&MATCH(A1,Sheet1!A:A,0)+1&":B50"),0))),"",(INDEX(INDIRECT("Sheet1!A"&MATCH(A1,Sheet1!A:A,0)+1&":A50"),MATCH("Y",INDIRECT("Sheet1!B"&MATCH(A1,Sheet1!A:A,0)+1&":B50"),0))))
And just drag the 2nd formula down.
Note that I assumed your first sheet is with 50 Rows as you wrote, Otherwise additional modifications needs to be made.
The formula you are looking for is quite complicated and requires cyclic calculation. For this reason, it is not advisable to use for long lists of several hundred or thousand 'names' but a list of 50 names should pose no discernible difficulties.
With the names in Sheet1's A2:A51, use this formula in the worksheet destined to receive the Y names.
=IFERROR(INDEX(Sheet1!$A$2:$A$51, AGGREGATE(15, 6, ROW($1:$50)/(Sheet1!$B$2:$B$51="Y"), ROW(1:1))), "")
Fill down as necessary. Note that the AGGREGATE¹ function is returning the position within A2:A51 with ROW(1:50).
Retrieving the non Y names should be a simple matter of changing the primary condition to (Sheet1!$B$2:$B$51="N") or (Sheet1!$B$2:$B$51<>"Y").
For pre XL2010 circumstances, this standard formula performs the same filtered retrieval.
=IFERROR(INDEX(Z!$A$2:$A$51, SMALL(INDEX(ROW($1:$50)+(Z!$B$2:$B$51<>"Y")*1E+99, , ), ROW(1:1))), "")
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.

Vlookup and get the min value (date)

TOP Table is Input, and bottom table is preview for required output.
For Each ID I need to find earliest datetime. I also need other information from other columns (please see image below).
My current solution is:
In Cell E2 =A2
Cell E3 drag down =IF(E2<>A3,IF(E1=A3,"",A3),"")
In Cell F2 drag down =IF(E2<>"",MIN(IF($A$2:$A$14=E2,$C$2:$C$14)),"") Ctrl+Shift+Enter
One more option without any intermediate calculations:
Select the whole range starting E2 and to the last row where IDs are located - for the sample given it's row 14, so select range E2:E14: =IFERROR(INDEX($A$2:$A$14,SMALL(IF(MATCH($A$2:$A$14,$A$2:$A$14,0)=ROW(INDIRECT("1:"&ROWS($A$2:$A$14))),MATCH($A$2:$A$14,$A$2:$A$14,0),""),ROW(INDIRECT("1:"&ROWS($A$2:$A$14))))),"") and press CTRL+SHIFT+ENTER instead of usual ENTER - this will define a Multicell ARRAY formula and will result in curly {} brackets around it (but do NOT type them manually!).
F2 (ID2): =IF(E2="","",SUMPRODUCT(--(E2=$A$2:$A$14),--(G2=$C$2:$C$14),$B$2:$B$14)) - normal formula.
G2 (Min Date): =IF(E2="","",MIN(IF(E2=$A$2:$A$14,$C$2:$C$14,2^100))) and press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in curly {} brackets around it (but do NOT type them manually!).
H2 (InCh): =IF(E2="","",INDEX($D$2:$D$14,SUMPRODUCT(--(E2=$A$2:$A$14),--(F2=$B$2:$B$14),--(G2=$C$2:$C$14),ROW(INDIRECT("1:"&ROWS($D$2:$D$14)))))) - normal formula.
Remarks:
To make the solution more compact and easy to read, define named range for ID column, and then reference other data columns using OFFSET.
ID2 values may not be unique - as they are on the sample for IDs 1...3.
Resulting set for Min Date should be formatted the same way as source Date row.
The key formula of the solution - is multicell monster which returns unique IDs without empty rows - as OP requested)
Sample file: https://www.dropbox.com/s/d2098updfh8djnf/MinDateIDs.xlsx
This is quite a challenge... I think I have found an approach that works. For the sake of clarity, I used a few helper columns. Also, I did not use any named ranges but stuck with the column-row indications. You might want to change that.
It looks like this:
and zooming in to the relevant columns:
Column F contains an array formula to filter out duplicates. An approach is explained here. The formula I used in F2 is
=INDEX($A$2:$A$14, MATCH(MIN(IF(COUNTIF($F$1:F1,$A$2:$A$14)=0, 1, MAX((COUNTIF($A$2:$A$14, "<"&$A$2:$A$14)+1)*2))*(COUNTIF($A$2:$A$14, "<"&$A$2:$A$14)+1)), COUNTIF($A$2:$A$14, "<"&$A$2:$A$14)+1, 0))
Use Ctrl-Shift-Enter to confirm as array formula. Drag this down or copy into column F. Then columns G and H contain the starting and ending indices of the duplicate ID values. This answer helped, please upvote it :-). The two formulas used are:
=MATCH(2,1/FREQUENCY($F2,$A$2:$A$14))
in G2, and
=FREQUENCY($A$2:$A$14,$F2)
in H2. Again, drag them down to get the full column filled. Next, column I is for clarification only -- and for sanity checking. It contains the desired minimum date from each sub-array. Column J substitutes that formula into a MATCH to find the actual index of the desired date.
=MIN(OFFSET($C$2:$C$14,$G2-1,0,1+$H2-$G2,1))
in I2 and
=$G2-1+MATCH(2,1/FREQUENCY(MIN(OFFSET($C$2:$C$14,$G2-1,0,1+$H2-$G2,1)), OFFSET($C$2:$C$14,$G2-1,0,1+$H2-$G2,1))
in J2. Finally, columns L, M and N index into the original set of data via
=INDEX(B$2:B$14,$J2)
in L2, which you can drag horizontally and then vertically.
When you are done, you can hide the helper columns, or fold everything into big formulas. Good luck with that... There might be an easier way to achieve this, but I did not find it.
If you want the value from column D in G then assuming that column C values are unique you could just use a VLOOKUP, i.e. in G2 copied down
=VLOOKUP(F2,C$2:D$14,2,0)
Per your picture, they're all in the same sheet. Just sort by ID, then Date (ascending). As you work your way down the ID column, each time the ID changes, you know you've found the row with the minimum Date for that specific ID. Create an extra column to signify where ID changes occur, and filter for those rows (hide the column if you so desire).
And... voila.
Know this link is old, but there is a much shorter and easier way!
How about using a pivot table using the Minimum as field setting and then do a =GETPIVOTDATA() to get the information back!
Seems a lot simpler as these formulas!
Actually, I just realized I've been overthinking this...Excel keeps the top item and removes all that follow when removing duplicates.
So if you are going to create an extra working table anyway, why not just copy the range/columns you want to keep, then use the basic sort.
Sort first by ID, then by the column you want as the second filter. Be sure the sorts are in the order you want (e.g. newest to oldest, oldest to newest, A to Z, Largest to smallest, etc).
Once the data is sorted, remove duplicates based on ID. You are left with all of your columns of data, filtered by newest/oldest/largest/smallest per individual.
This worked for my table with 30,000+ records, filtered down to 1500 unique individuals with most recent (plus associated amount), and with a second filter, the largest (plus associated date) for each person.

Resources