Multiple criteria for index match - indexing

=INDEX([Book1.xlsx]Sheet1!$F:$F,MATCH(S2&B2,[Book1.xlsx]Sheet1!$E:$E,0))
Used this formula to pick 2 criteria i.e, data code and record type to arrive at GL account. But the result is #NA error. Also, used concatenate formula and merged the criteria and did vlook up but the error #NA still remains. enter image description herePlease suggest.

Your question is not very clear. I will assume that the table you pasted a picture of is the table you want to RETRIEVE "GL Account" from. I'm not sure why this table would already have an #N/A in it, but know that if you have an #N/A in your lookup table, it's possible for a correctly working formula to return an #N/A, because that's the value it found.
I used tables/columns with intuitive names to make it easier to follow the formula:
=INDEX(LookupTable[GL Account],MATCH([#[Value to use in lookup]],LookupTable[Lookup Value],0))
I don't see anything fundamentally wrong with the formula you posted, but it's just not clear what you are doing with it, what data is in which cells, etc. But hopefully this helps you.

Related

Formula-based list for data validation

Please refer to the image attachment below. I want to ask for help regarding the semi-automation of the values D2:D6. Currently, they have the following formula:
=IF(C2="n/a",$D$12,IF(C2="","",IF(OR(TODAY()=C2,TODAY()>C2),$D$11,$D$10)))
Column C on the other hand has the following formula:
=IF(B2="n/a","N/A",IF(B2="","",$B$8-$B2))
Basically, what these formulas do is that after I input a value 'x' at column B, column C automatically indicates the date 'x' days before the start date on B8. Column D then indicates whether the deadline is due, not due, not applicable, or ready (D2:D6 is data validated with a list including D9:D13).
However, if a certain action is already completed, the "Ready" option is manually selected from the drop down list, which then erases the formula. What I wish to ask for help with is how do I return the erased formula in case the "Ready" option is just accidentally selected, or if my (not excel-capable) peers will need to reuse the form by just deleting items in column A and B.
What I tried doing was making the formula itself an option in the drop down list, but this doesn't adjust to the cell addresses for each item, and only shows one static value.
One option I thought of was to limit the data validation list with just the "Ready" option, so that the user can just delete the cell. A VBA code will then detect the blank cell and will return the formula it initially had. Unfortunately, I don't really know VBA or any programming. I can however understand and have managed to use and modify VBA codes posted in the internet according to my previous needs. I tried searching for a code, but to no avail.
If you could give me good references (not a whole book please) relative to this, I would really appreciate it. If you're feeling benevolent and help me with the coding, thanks! However, if there's a non-VBA solution, then I would really like to know more about this. Thanks all!
Sample list

Query several ranges and add automatically a column to know the source of each row

I am trying to achieve the following in Google Spreadsheets.
First, I want to query several ranges (in different sheets from the same spreadsheet). I tried a formula like this =query(arrayformula({indirect(E2:E10)}),"select * where Col1 <>''") with no success
In E2:E10 I have a list of ranges. Column F contains a name that describes the source of the value in Column E.
My second problem is that I need to add a column to the output of that query that tells me the origin of each row.
If the sources are ranges of 3 columns by country I need to merge those tables and add that country to each row.
All credits to +Ben Liebrand who helped me out here: https://support.google.com/docs/profile/3464
"I just want to start of by saying that the indirect() function does not work in an arrayformula() function as expected. So you will need to take another approach. I can understand what you are trying to do so I added another TAB in your spreadsheet to demonstrate another approach. I know it was initially a specific design you were trying so I made some changes to what you had. Maybe you can take a look at what I have offered and maybe you can tweak your design.
I know what I am offering is just very rough but you will also notice that I removed the end row specifier from your ranges in the range table.
Don't assume my example to be the final result but I was just trying to show that the range you were trying to use with the indirect() function will not work.
So hopefully this will give you a new idea of how you can maybe handle this.
My formula also adds the country to each of the tables in the output. My formula looks like this
=query(ArrayFormula({
if(len(indirect(regexextract(F2,"\w+\!\w+")&":A")),G2,),indirect(F2);
if(len(indirect(regexextract(F3,"\w+\!\w+")&":A")),G3,),indirect(F3);
if(len(indirect(regexextract(F4,"\w+\!\w+")&":A")),G4,),indirect(F4);
if(len(indirect(regexextract(F5,"\w+\!\w+")&":A")),G5,),indirect(F5);
if(len(indirect(regexextract(F6,"\w+\!\w+")&":A")),G6,),indirect(F6);
if(len(indirect(regexextract(F7,"\w+\!\w+")&":A")),G7,),indirect(F7)
})," select * where Col1 <> '' ")
Hope this is of some help to you"
And I hope is useful to the community
Gerónimo

Excel VBA Conditionally Remove Duplicates By Lookup Value

I wasn't quite sure how to title this question, but it's as concise as I could think of. Sorry if it's junk.
I have a list created on Sheet2 based on info from Sheet1. What I'd like to do is examine ColumnA and remove duplicate rows if the matching value on Sheet1 ColumnB's offset ColumnE doesn't equal "SUB-ASSY".
Basically:
Find the value from Sheet2, ColumnA on Sheet1, ColumnB.
Get the value from Sheet1, ColumnE
If it does NOT match "SUB-ASSY", delete any duplicates on Sheet2
This should leave one instance of all non-subassembly entries and leave subassemblies alone.
Does this make any sense?
I think I need to do some INDEX/MATCH or VLOOKUP, but I don't know if that'd be the right way to go (or exactly how I'd do it). Does anyone have a good way to do this?
I appreciate any help. I can include the workbook if needed, but it looks up a bunch of stuff on an sql server, so it might not work correctly if you can't connect.
Thanks Again,
-stu
Are you looking for a general idea on how to do this, or a VBA macro?
One way I'm thinking that could get you going is in your second sheet (which, in the end, will have only unique entries) create a 'helper column'. Let's say Column F is empty. You can do a simple "if" statement that will check for the value on that row, in column A is in that other sheet. If so, return "DUPLICATE" (or some note, "Duplicate, delete", etc.). Then run that down the columns, then sort that whole table by your new column. This will sort all the duplicate values in one big block, which you can highlight and delete.
It could help if you show a little bit of what the data looks like on your Sheet1 and Sheet2 (can be made up data, doesn't have to be SQL server info).

Function that searches for the exact same date or the closest one in the past + one extra condition

This is a continuation of " Is it possible to write a VBA code that searches for the exact same data or the closest one in the past? "
Basically I would like to expand the function that #Jeeped posted but for some reason it's not going as planned eventhough I'm doing the same stuff he showed.
The extra condition in this case is that the machine used to produce the juice must be equivalent to the machine of the parameters.
(the image of what I'm doing)
Basically if a juice is made on 29/09 with machine M0 for example then I want to have the parameters that were used for that juice. Obviously the parameters of 30/09 weren't used but the parameters of 25/09 for machine M0 were used.
I edited the code #Jeeped posted in my previous question to the following
=IFERROR(INDEX(C$2:C$10, MIN(INDEX(ROW($1:$10)+($A$2:$A$10>$F2)*1E+99+($B$2=$G$2),,))),"")
But I get an error and I'm not sure why but I have a feeling it has to do with what I wrote ($B$2=$G$2) but how do I fix it?
DISCLAIMER: the percentages used are fictive, it's just a function I need to get working for several Workbooks that will automate some work I need to do every month.
It looks like you want to add the condition that columns B should match G2. This should do the trick.
=IFERROR(INDEX(C$2:C$10, MIN(INDEX(ROW($1:$9)+(($A$2:$A$10>$F2)+($B$2:$B$10<>$G2))*1E+99,,))),"")
This type of formula does not make direct matches. It excludes everything that doesn't match and then accepts whatever is left over. So like the date in F2 is compared to the dates in column A and anything that is larger (i.e. later) is multiplied by a very large number. We do the same to the machine ID in G2. Anything that does not match the machines in column B get multiplied by the same very large number. By mathematically excluding anything that doesn't fit, we are left with what does fit.
It is also important to note that the ROW(1:9) is the position within C2:C10 or A2:A10, not the actual row on the worksheet.
Addendum: With the dates now unsorted, I can provide both a standard and an array formula to compensate. The array formula for I2 is,
=SUMIFS(C$2:C$10,$A$2:$A$10,MAX(IF($A$2:$A$10<=$F2,IF($B$2:$B$10=$G2,$A$2:$A$10))),$B$2:$B$10,$G2)
This must be finalized with Ctrl+Shift+Enter rather than simply Enter. Once entered correctly, it can be filled both right and down. Next is a standard formula that does not require Ctrl+Shift+Enter but accomplishes the same thing. Your results should resemble the following image.
=SUMIFS(C$2:C$10, $A$2:$A$10,MAX(INDEX(($A$2:$A$10<=$F2)*($B$2:$B$10=$G2)*($A$2:$A$10),,)),$B$2:$B$10,$G2)
    
I think the formula below might answer your question. Please see the image for reference.
Formula Used: =INDEX($D$2:$E$7,MATCH(1,($B$2:$B$7<$H3)*($C$2:$C$7=$I3),0),1)
Please note - this requires your date of parameter change to be sorted from newest to oldest.
To apply this formula, press CTRL+SHIFT+ENTER after writing the formula. This is required for excel to understand that this should function as an Array formula. On doing so, excel will automatically add the curley brackets at the beginning and end of the formula as can be seen in the image.
Only small difference for formula to get %Oranges will be replacing the last 1 by 2.
INDEX($D$2:$E$7,MATCH(1,($B$2:$B$7<$H3)*($C$2:$C$7=$I3),0),2)
Hope this answers your question. Please let me know if you need further assistance.

Excel - How do I find all relevant rows by typing unique invoice# listed Col A

I have a Worksheet with 10 columns and data range from A1:J55. Col A has the invoice # and rest of the columns have other demographic data. Goal is to type the invoice number on a cell and display all the rows matching the invoice number from col A.
Besides auto filter function, the only thing comes to my mind is VBA. Please advice what is the best way to get the data. Thanks for your help in advance.
Alright, I'm pretty proud of this one. Again avoiding VBA, this one uses the volatile formula OFFSET to keep moving its VLOOKUP search down the table until it's found all matches. Just make sure you paste enough rows of the formula that if there are many matches, there's room for all of them to appear. If you put a border around your match area then it would be clear if you ever ran out of room and needed to copy down the formula some more.
Again, in the main section, it's just a single formula (using index):
=IFERROR(INDEX($A$1:$J$200,$M3,MATCH(N$2,$A$1:$J$1,0)),"")
This gets to be so simple because the hard work of the lookup is done by an initial column which looks up the next row that matches the invoice number. It has the formula:
=IFERROR(MATCH($L$2,OFFSET($A$1:$A$200,M2,0),0)+M2," ")
Here is the working example that goes with those formulas:
Let me know if you need any further description of how it works, but it mostly uses the same rules as above so that it's robust in copying and moving around.
I've uploaded the Excel file so you can play with it, but everything you need to reproduce this feature should be in this solution.
Google Docs - Click link and hit Ctrl+S to download and open in Excel.
A popular solution to this problem is a simple VLookup. Lookup the invoice the user types in on the table A1:J55, and then return an adjascent column's data.
Here's an example of it working:
The formula in the highlighted cell is:
=VLOOKUP($L3,$A:$J,MATCH(N$2,$1:$1,0),FALSE)
What's nice about this formula is you only need to type it once and then you can copy it across and it'll automatically pick out the correct column of the table (that's the match part). The rest is very simple:
The first part says lookup value $L3 (the invoice number typed in),
The second part says look it up in range $A:$J (which is where your table is located). I've shown how you can select the entire columns $A:$J so that you can add and remove data without worrying about adjustin the range in your lookups. (Excel takes care of optimizing the formula so that unused cells aren't checked)
The third part picks the column from which the resulting data will be drawn once a matching row is found.
The FALSE part is an indication that the invoice number must match exactly (no approximate matching allowed)
The $ signs ensure that fixed ranges like the location of your source table ($A:$J) and your lookup value ($L3) don't get automatically changed as you copy the formula across for multiple columns.
The formula is pretty easy to adapt if you want to move around your table and the area where you do your lookup. Here's an example:
Bonus
If you want to add a little spiff, you can add a dropdown to the Invoice # field so that the user gets auto-completion and the option to browse existing values like so: