I have a table with some numbers stored as text (UPC codes, so I don't want to lose leading zeros). COUNTIF() recognizes matches just fine, but MATCH() doesn't work. Is there a reason why MATCH() can't handle numbers stored as text, or is this just a limitation I'll have to work around?
Functions like MATCH, VLOOKUP and HLOOKUP need to match data type (number or text) whereas COUNTIF/SUMIF make no distinction. Are you using MATCH to find the position or just to establish whether the value exists in your data?
If you have a numeric lookup value you can convert to text in the formula by using &"", e.g.
=MATCH(A1&"",B:B,0)
....or if it's a text lookup value which needs to match with numbers
=MATCH(A1+0,B:B,0)
If you are looking for the word test for example in cell A2, type the following:
=MATCH(""&"test"&"",A2,0)
If this isn't working then try =Trim and =Clean to purify your column.
If =Trim and =Clean don't help, then just use the left 250 characters...
(As the Match Formula may encounter a timeout/overflow after 250 characters.)
=Left(A2, 250)
If you are using names to refer to the ranges, once you have fixed the datatypes also redefine any names which refer to those ranges.
Related
I have a table where underlying database stores numbers as text. In this case, the greater than or equal operator doesn't capture the first value.
This formula ignores the first row of the data in the result where AcctNum=123. The formuula returns 11 when it should return 21.
=SUMIFS(Table1[Balance],Table1[AcctNum],">='123'", Table1[AcctNum],"<='500'")
Things I have tried:
1. "*" wildcard.
2. Many combinations of T() and TEXT() Function.
Things I don't want to do:
1. Use arrays.
2. Add columns to my table that are converted to numeric, because not all AcctNum's are formatted the same way, which is why they must remain text.
3. Use SUMPRODUCT because readability of formula is important in this case.
I have written a custom function to work around the problem, but I would like to know if there is a natural Excel solution. I have read SUMIF and SUMIFS do not work well when numbers are stored or retrieved from database as text. I am using Excel 2016.
Try SUMPRODUCT with double minuses to convert the text and booleans to numbers.
=SUMPRODUCT(--(--Table1[acctnum]>=123), --(--Table1[acctnum]<500), Table1[balance])
What do you mean by 2. Add columns to my table that are converted to numeric, because not all AcctNum's are formatted the same way, which is why they must remain text?
You can do this with an array or a helper column, other than that, not sure if it's possible using SUMIFS.
If you use Sumproduct, you can explicitly convert the text to numbers.
=SUMPRODUCT(Table1[Balance],--(Table1[AcctNum]+0>=123),--(Table1[AcctNum]+0<=500))
This pictures shows my table and formula's yield
I have used following formula to extract result from a table.
Its working perfectly fine but I am hoping to level up my understanding of Excel formulas.
The trouble is that I use IF in Excel way to often.
what I wanted to know is if its possible to use a different approach, something that can work similar to if but is perhaps more sophisticated.
=IF(OR(J2="08L",J2="08R"),IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$34,0)),"LAM",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$35:$E$35,0)),"West",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$36:$G$36,0)),"East",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$37,0)),"SFD",NA())))),0)
I very much appreciate any help.
Now that there is an example, I think this is a good question. You've recognised that your formula is fairly messy and also can't be easily expanded if there are more routes.
The problem is that Excel is very good for searching for a value in a single row or column, but not as good for searching for a value in a block of data.
You can simplify this problem by creating an additional column that has each entire route in a single cell. You can do this just by concatenating values. In your example, use column H:
=B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2
This will create a string with the entire route in a single cell. Spaces are added in between each part of the route to make sure you don't accidentally create a sequences of letters that matches part of another route. It doesn't matter if there are blank cells, there will just be some extra spaces at the end which doesn't matter. Fill this down the column to get the entire path for each route in a single cell.
Then, you can create a formula that tries to find the 3 letters anywhere in any of the full routes.
=INDEX($A$2:$A$5,MATCH("*"&left(I2,3)&"*",$H$2:$H$5,0))
This formula is basically a deconstructed vlookup. It determines where the 3 characters can be found in column H, then gives back the corresponding value from column A.
The MATCH function tries to find the left 3 characters of I2 in column H. The MATCH function normally tries to find a complete exact match (with the last parameter being equal to 0), but we can just add wildcards to the search value. The MATCH function then returns the index of the range where it was found. I.e., if it was found in the 2nd cell of the range H2:H5, it returns the number 2.
The INDEX function then just gets a value from a range based on an index. In this case, it will get the 2nd value from range A2:A5.
I have a column full of text/string values. Some of the values appear to be null, but in reality have some formatting (additional spaces) left over from the exporting program where I get the excel data. I am trying to create an array using all capitalized letter of the English alphabet to cypher through each cell in the column, looking for the instance of any of the alphabet's letters within the first letter of each cell in the specific column, and if not found, returning a completely blank value in the neighboring column. If a letter value is found, then it would return the entire value of the cell. This way I can have true blanks and will be able to sort things a bit better.
I have been trying to find a working argument to build off of but aside from the
LEFT(Cell,1)="A-Z"
I have found little that seems to be a viable workaround. Any help is appreciated! Thanks!
You will want to use the ascii value to check for A-Z. Assuming the data is in the A column you can use the formula below. ASCII value range 65=A 90=Z. The trick is the Code formula which returns the ascii numeric value. Then an if statement to check if it is between the range, If it is return the cell contents and if not return nothing. You can also use Clean() to remove any unprintable characters (that is not used in this example)
=IF(CODE(UPPER(LEFT(A1,1))) > 64, IF(CODE(UPPER(LEFT(A1,1))) < 91,A1,""))
I'm not sure why my VLOOKUP formula is not working like the screenshot below. The value is right there as highlighted. I want to output the value in Column G, but changing the 3rd parameter to 1 or 2 doesn't work.
Help is appreciated. Thanks much in advance.
Formula: =VLOOKUP(B2,$F$1:$G$421,2,FALSE)
One thing you may want to look at.
I notice your data is left justified and that's normally the case for textual rather than numeric fields - it's possible to left justify numerics but it's neither the default nor the general practice.
If they are textual, there's a chance one or more of them may have leading or trailing spaces. That would prevent the lookup from finding a match.
Select (in turn) B2 and F1 and use the arrow keys in the formula box to check this is not the case.
In cases like this, I tend to (temporarily) set B2 to the formula =F1 just to see if it can find a match that's guaranteed (then use CTRL-Z to revert).
If that change results in the lookup working then obviously the (original) B2 and F1 are not the same value, and you need to work out why (hidden spaces, wrong types, and so on).
It looks like you are comparing text to number (see the green triangle in your value cell). You have to convert the value in your source cell or matching cells to same type. To convert source to number use excel function such as int or value. Hope this helps.
Another way to convert text to number format is to multiply by 1 and then replace original text values with these new number values...
If you are doing lookup where you have a mix of text and numbers (i.e. looking up a text version of a number in a list of real numbers) you can also make use of the VALUE function... this will convert numbers stored as text to real numbers.
Embed it like so:
=VLOOKUP(VALUE(B2),$F$1:$G$421,1,FALSE)
If you have a mix of text numbers and text text to look up in numbers/text then you can do:
=VLOOKUP(IFERROR(VALUE(B2),B2),$F$1:$G$421,1,FALSE)
to change numbers stored as text to numbers, but leave other text as is...
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.