VLOOKUP and Transform a table inside the formula - excel

I'm not sure if this is possible but I have this table:
What I want to achieve here is to get the last three character of the lookup value and transform the table being referenced in VLOOKUP into their last three character without having to create a new excel table filled with last three character of the table being referenced.
Here's how I tried it but since RIGHT(A:A,3) cannot be done, is there any alternative way to code this in one straight line?
=VLOOKUP(RIGHT(B2,3),RIGHT(A:A,3),1,FALSE)

As per your explaination, it looks like you need to use wildcards. Within VLOOKUP:
=VLOOKUP("*"&RIGHT(B2,3),A:A,1,FALSE)
But I would suggest get in the habit of using INDEX and MATCH combo, since it's faster:
=INDEX(A:A,MATCH("*"&RIGHT(B2,3),A:A,0))

Related

Data from Rows to a Single Column? (Cell Formula)

Is there a way to convert data from a row-array over to a single column, without breaks, using cell formulas?
Example Table:
The following explanation does what you are looking for, EXCEPT it also includes the empty (unanswered) questions. I can't think of a way to do also remove the empty ones.
source: https://www.extendoffice.com/documents/excel/2775-excel-convert-matrix-to-single-column.html
Another way would be to use VBA

How to specify multiple ranges in excel filter formula

I would like to be able to use Excel's filter formula and get only specific columns as a result.
For example, I tried the below formula and failed.
=FILTER((A:B,D:D),A:A=3475,"")
How can I get this working? I want to get the filtered result where any value in column A equals 3475, and only get columns A,B and D
You could use a single one formula like:
=TRANSPOSE(CHOOSE({1,2,3},FILTER(A:A,A:A=3475),TRANSPOSE(FILTER(B:B,A:A=3475)),TRANSPOSE(FILTER(D:D,A1:A4=3475))))
But considering performance, I'd go with two seperate formulas as proposed in the comments.
You need use the proper array for the array argument to the filter function.
I used a Table since using whole-column references is inefficient.
For example, if you want to return only columns 1,2 and 4 of a table, you can use:
=INDEX(Table1,SEQUENCE(ROWS(Table1)),{1,2,4})
So your filter function might be:
=FILTER(INDEX(Table1,SEQUENCE(ROWS(Table1)),{1,2,4}),Table1[colA] = myVar)
IF, for some reason you don't want to use Tables, the following formula should also work:
=FILTER(INDEX($A:$D,SEQUENCE(LOOKUP(2,1/(LEN($A:$A)>0),ROW($A:$A))),{1,2,4}),myVar=INDEX($A:$A,SEQUENCE(LOOKUP(2,1/(LEN($A:$A)>0),ROW($A:$A)))))
as would, the less efficient:
=FILTER(INDEX($A:$D,SEQUENCE(ROWS($A:$A)),{1,2,4}),myVar=$A:$A)

Extract a Word from String Containing a Specific Multiple Words

"I'm setting up a pivot in excel, and want to extract specific words from a data set of text.
I have tried using the below formula to extract one particular word, but want to nest the multiple formula to extract other words as well
=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",99)),MAX(1,FIND("Evaluation",SUBSTITUTE(A1," ",REPT(" ",99)))-50),99))
The above formula works but only for one word. I want to create nested formula to search first word or second word or third...
If your goal is to search an array for a a substring, if that substring matches any words in a list, and if so, return the matched substring, as in the post suggested by JvdV, use the formula below, which I have modified.
I recommend, in a different worksheet, add a table with a list of the words you want to find, like this. Highlight the range of cells, including the header, then Home > Format as Table > pick a table style and give it a name. This table's name is "t_WordsToFind" (so I can easily identify it in other functions later). You may want to also put your primary data into a table as well. My go-to name is usually "t_Data". Now, instead of worrying about column numbers/letters, you have the user-friendly column headers you started with which makes reading the formula much easier. Your table ranges will also automatically expand when addtl data is added, so row numbers don't need to be referenced any more either.
If you don't have your data in tables, use this version of the formula, and remember to update your range parameters when data is added. B2 is the first cell to be searched, D2:D4 is the list of words to look for, copy the formula down. I do prefer not to use IFERROR as it includes many different types of errors that I may need to know about, like if I misspelled the function name, for example. If you simply need to have an alternative in the event no matches are return and your function is valid, I recommend IFNA.
IFNA(LOOKUP(1,1/COUNTIF(B2,"*"&$D$2:$D$4&"*"),$D$2:$D$4),"")
If you do use tables for your data and lookup tables (you are very wise) and here is the formula version to use (below). In this example, #[Search This Column] is the the equivalent to B2 and t_WordsToFind[Find This] is the table name and column name of words to look for, but it's much more legible, and doesn't need to be copied down or manually expanded in the future.
IFNA(LOOKUP(1,1/COUNTIF([#[Search This Column]],"*"&t_WordsToFind[Find This]&"*"),t_WordsToFind[Find This]),"")
Even wiser still, assuming this is a perpetual need, would be to use power query/power pivot, but I don't want you to go into TMI overload.
Also, your pivot table range will be nice and easy, "t_Data".

Simpler formula for a 5 nested if command

I have been scouring forums for a solution but am striking out so far. I want to do a countA of all non empty cells -1. The data I'm pulling from is in Q:U, and I want to do a count based on the header of the columns in row 2. Because of where the data comes from in Q:U, the column order is not always going to be the same.
I have the following string which works where I can replace each instance of "Test" with the particular header I am looking for. Is there a simpler command using a combination if Index and Match that would work? Or even a better solution?
=IF($Q$2="Test",COUNTIF($Q$3:$Q$150,">0")-1,IF($R$2="Test",COUNTIF($R$3:$R$150,">0")-1,IF($S$2="Test",COUNTIF($S$3:$S$150,">0")-1,IF($T$2="Test",COUNTIF($T$3:$T$150,">0")-1,IF($U$2="Test",COUNTIF($U$3:$U$150,">0")-1,0)))))
use:
=COUNTIF(INDEX($Q$3:$U$150,0,MATCH("Test",$Q$2:$U$2,0)),">0")-1
You can replace "Test" with a cell reference that you then can change to look up different columns by their name.

Using SUMIFS with multiple AND OR conditions

I would like to create a succinct Excel formula that SUMS a column based on a set of AND conditions, plus a set of OR conditions.
My Excel table contains the following data and I used defined names for the columns.
Quote_Value (Worksheet!$A:$A) holds an accounting value.
Days_To_Close (Worksheet!$B:$B) contains a formula that results in a number.
Salesman (Worksheet!$C:$C) contains text and is a name.
Quote_Month (Worksheet!$D:$D) contains a formula (=TEXT(Worksheet!$E:$E,"mmm-yy"))to convert a date/time number from another column into a text based month reference.
I want to SUM Quote_Value if Salesman equals JBloggs and Days_To_Close is equal to or less than 90 and Quote_Month is equal to one of the following (Oct-13, Nov-13, or Dec-13).
At the moment, I've got this to work but it includes a lot of repetition, which I don't think I need.
=SUM(SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Oct-13")+SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Nov-13")+SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Dec-13"))
What I'd like to do is something more like the following but I can't work out the correct syntax:
=SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,OR(Quote_Month="Oct-13",Quote_Month="Nov-13",Quote_Month="Dec-13"))
That formula doesn't error, it just returns a 0 value. Yet if I manually examine the data, that's not correct. I even tried using TRIM(Quote_Month) to make sure that spaces hadn't crept into the data but the fact that my extended SUM formula works indicates that the data is OK and that it's a syntax issue. Can anybody steer me in the right direction?
You can use SUMIFS like this
=SUM(SUMIFS(Quote_Value,Salesman,"JBloggs",Days_To_Close,"<=90",Quote_Month,{"Oct-13","Nov-13","Dec-13"}))
The SUMIFS function will return an "array" of 3 values (one total each for "Oct-13", "Nov-13" and "Dec-13"), so you need SUM to sum that array and give you the final result.
Be careful with this syntax, you can only have at most two criteria within the formula with "OR" conditions...and if there are two then in one you must separate the criteria with commas, in the other with semi-colons.
If you need more you might use SUMPRODUCT with MATCH, e.g. in your case
=SUMPRODUCT(Quote_Value,(Salesman="JBloggs")*(Days_To_Close<=90)*ISNUMBER(MATCH(Quote_Month,{"Oct-13","Nov-13","Dec-13"},0)))
In that version you can add any number of "OR" criteria using ISNUMBER/MATCH
You can use DSUM, which will be more flexible. Like if you want to change the name of Salesman or the Quote Month, you need not change the formula, but only some criteria cells. Please see the link below for details...Even the criteria can be formula to copied from other sheets
http://office.microsoft.com/en-us/excel-help/dsum-function-HP010342460.aspx?CTT=1
You might consider referencing the actual date/time in the source column for Quote_Month, then you could transform your OR into a couple of ANDs, something like (assuing the date's in something I've chosen to call Quote_Date)
=SUMIFS(Quote_Value,"<=90",Quote_Date,">="&DATE(2013,11,1),Quote_Date,"<="&DATE(2013,12,31),Salesman,"=JBloggs",Days_To_Close)
(I moved the interesting conditions to the front).
This approach works here because that "OR" condition is actually specifying a date range - it might not work in other cases.
Quote_Month (Worksheet!$D:$D) contains a formula (=TEXT(Worksheet!$E:$E,"mmm-yy"))to convert a date/time number from another column into a text based month reference.
You can use OR by adding + in Sumproduct. See this
=SUMPRODUCT((Quote_Value)*(Salesman="JBloggs")*(Days_To_Close<=90)*((Quote_Month="Cond1")+(Quote_Month="Cond2")+(Quote_Month="Cond3")))
ScreenShot
Speed
SUMPRODUCT is faster than SUM arrays, i.e. having {} arrays in the SUM function. SUMIFS is 30% faster than SUMPRODUCT.
{SUM(SUMIFS({}))} vs SUMPRODUCT(SUMIFS({})) both works fine, but SUMPRODUCT feels a bit easier to write without the CTRL-SHIFT-ENTER to create the {}.
Preference
I personally prefer writing SUMPRODUCT(--(ISNUMBER(MATCH(...)))) over SUMPRODUCT(SUMIFS({})) for multiple criteria.
However, if you have a drop-down menu where you want to select specific characteristics or all, SUMPRODUCT(SUMIFS()), is the only way to go. (as for selecting "all", the value should enter in "<>" + "Whatever word you want as long as it's not part of the specific characteristics".
In order to get the formula to work place the cursor inside the formula and press ctr+shift+enter and then it will work!
With the following, it is easy to link the Cell address...
=SUM(SUMIFS(FAGLL03!$I$4:$I$1048576,FAGLL03!$A$4:$A$1048576,">="&INDIRECT("A"&ROW()),FAGLL03!$A$4:$A$1048576,"<="&INDIRECT("B"&ROW()),FAGLL03!$Q$4:$Q$1048576,E$2))
Can use address / substitute / Column functions as required to use Cell addresses in full DYNAMIC.

Resources