In MS Excel, I'm trying to make a wildcard search using the SUMIF function. I'm following this guide. However, for some reason my Excel doesn't think the words in the range are equal to the criterion.
Suppose I have the following data:
I have apple as a criterion and want to find sum all the cells adjacent to one containing the word apple. My formula is:
=sumif(A2:A6, "*apple*", B2:B6)
Now, for some reason the result of the sum function amounts to nothing.
I also tried another test, which I think my error has to do with. If I type = "apple" = "*apple*", Excel returns False`. The two are related, I think, but I don't see how I can solve my original problem.
Any help is much appreciated.
Try
=sumif(b2:b6,"*apple*",a2:a6)
As according to your example you have the sum range first followed by the range you are controlling against.
That is the wrong way round for sumif().
Related
I have two lists of products in Excel. Each list will be of varying length each month.
Is there a way to combine the two lists into a third list, with the second list being underneath the first?
I would like to do this avoiding macros.
I image this could be done using Dynamic Arrays, but I can't figure it out.
Please see an example below:
Thank you so much in advance.
I have had this problem before and used this tutorial to help me. I attach the example sheet also, which provides the formula that may work for your problem.
See the image below for cell references - then try this:
=IFERROR(INDEX($B$3:$B$7, ROWS(H2:$H$2)), IFERROR(INDEX($D$3:$D$4, ROWS(H2:$H$2)-ROWS($B$3:$B$7)), IFERROR(INDEX($F$3:$F$6, ROWS(H2:$H$2)-ROWS($B$3:$B$7)-ROWS($D$3:$D$4)), "")))
I have managed to find a solution that works for me, where the lists are of variable length.
Using a similar scenario to Mardi-Louise's answer, I am using the following formula in cell F3, and then dragging down:
=IF(B3<>"",B3,OFFSET($D$3,ROW()-COUNTA($B$3:$B$7),0))
Explanation:
So long as List 1 is not finished, it takes the value from List 1.
Once List 1 is finished, it begins at the top of List 2, and uses an offset to move down.
I'm late to the party, but for anyone still looking for this there's (now) a function for this in Excel 365: vstack(array1;array2;...)
Here is Microsoft's page on it
With the arrays as columns in tables you'll get dynamic lengths. It's also possible to combine vstack() with for example unique().
I benefitted from Answer 2 with slightly different syntax. The ROW() function provides an output based on the absolute cell address when an output based on the relative position of the list is actually more generally applicable. I found the following syntax works better to reference the output of ROW() to the cell above the top cell of range D3:D8:
=IF(B3<>"",B3,OFFSET($D$2,ROW()-ROW($D$2)-COUNTA($B$3:$B$7),0))
Additionally, the COUNTA function can provide inconsistent results when cells in the range are not based on simple data but on the output of formulas which can be equal to 0 or blank without actually being empty. In that case COUNTIF often works better such as:
=IF(B3<>"",B3,OFFSET($D$2,ROW()-ROW($D$2)-COUNTIF($B$3:$B$7,"<>"&0),0))
I need to count how many cells in a table column that contains a specific text string. I'm using this formula and it works well:
=COUNT.IF(TB_table_name[col_name];"*string_to_be_found*")
But I need to count only filtered cells.
I've found may solutions (using SUMPRODUCT) on internet, but only to common cells and not table conlumns.
This is the kind of table that I have:
As you can see, there are many values in the same cell (It happens because it is generated automatically by a survey made in MS Forms). Because of this, I need to search for a specific string to be counted.
Using "COUNT.IF" I have this results:
Please observe that the values in the cell are not random, but predefined - of course the sequence could not be the same, but the list of possible terms are.
Please, can you help me figure this out? Belive me, I have tried many things but nothing worked and it seems to be a thing so easy to achieve :(
The trick is to combine a couple of the ideas you found using SUMPRODUCT.
You likely found this reference (or one just like it) that gave guidance for a formula like this:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(B2:B7,ROW(B2:B7)-MIN(ROW(B2:B7)),,1))*(B2:B7="Quality"))
Which translates to your problem-space like this:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(TB_table_name[col_name],ROW(TB_table_name[col_name])-MIN(ROW(TB_table_name[col_name])),,1))*(TB_table_name[col_name]="*string_to_be_found*"))
This works perfectly fine if you're NOT using a wildcard search. But that's what you need. So in this answer it shows that the wildcard in a SUMPRODUCT needs to use the -- operator. So the result is to combine the two answers and you get:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(TB_table_name[col_name],ROW(TB_table_name[col_name])-MIN(ROW(TB_table_name[col_name])),,1))*(--(ISNUMBER(FIND("string_to_be_found",TB_table_name[col_name])))))
Notice that the string_to_be_found does NOT have wildcard * specifiers. That's taken care of by the FIND function.
I'm using counting invoice numbers (text) in a table's column, but the Excel formula seems to be confusing some values.
I copied small sample of these - please refer to below:
The formulas are as follow:
=COUNTIFS(A1:A19,A1)
=COUNTIF(A1:A19,A1)
As you can see these invoice numbers differ and the results of these functions suggest as if all were the same.
I googled it for 1 hour but I didn't find such as issue as mine.
If anybody had any clue why could this behave in such way I'll be super grateful!
Rob
Each time you copy down this formula it will add 1 row to each. For example the second row of datas formula will be =COUNTIFS(A2:A20,A2). To lock these cells in the formula use $
Your formula should be =COUNTIFS(A$1:A$19,A1)
I've solved this myself:
ROOTCAUSE
Excel tried to be helpful and read these invoice numbers as actual numbers (despite these being defined already in Power Query as text)
Then, Excel fooled me and despite showing that it works on it as a string (I was evaluating the formula) it worked on it as number
Above means that it transformed exemplary "00100001010000018525" to 1.00001E+17, which cut down this to "100001010000018000" - that's the moment Excel stopped fooling around and showed that value in the formula bar.
I think I don't need to tell why countif perceived all these values as equal.
SOLUTION
I simply appended one letter after each invoice number to get e.g. "00100001010000018525a" what forces Excel to quit its gimmicks and games.
Case closed.
I suspect this is a bug in COUNTIF, or maybe by design.
However, to workaround this in the formula, without having to change your data, try adding a wild-card character:
=COUNTIF(A1:A19,"*"&A1)
I have a long list of part numbers where I need to be able to lookup and retrieve information on them.
These parts can have several alternative part numbers. I have figured out how to get the data returned if my data table only shows one of the possibly part numbers.
The issue is that I want it to be able to look up the columns to find a matching value.
As in the picture below for example. 5-E26 is the equivalent to E5-25. So if I input 5-E26 in the cell, I want it to continue searching to find the value in B7, and return the data as done A4 and A5.
Is this possible to do with Vlookup? Or is there a smarter method for it?
I struggle to fully understand how your data works but here is a possibility:
So the translated version of the formula I used in G2:
=INDEX($D$1:$D$5,AGGREGATE(15,3,((($A$2:$D$5=F2)/($A$2:$D$5=F2))*ROW($A$2:$A$5)),1))
You could also try (in my case):
=INDEX($D$1:$D$5,SUMPRODUCT(($A$2:$D$5=F2)*ROW($A$2:$D$5)))
I have a bank export of Credit card vendors. As these vary, I use unique strings contained in each to identify them. For example here is a lookup table excerpt.
First Lookup
I then apply a formula =INDEX(First_level,MATCH(TRUE,ISNUMBER(SEARCH(Keywords,C3374)),0)) to produce this:
First calc
I found this formula here https://exceljet.net/formula/get-first-match-cell-contains
Then I reapply the formula to the result ie the First_Level using this formula =INDEX(Second_Level,MATCH(TRUE,ISNUMBER(SEARCH(Frst_Lev_Check,H44)),0)) with this Lookup.
Second Lookup
Most of the time it works, but for this I get the following
Second calc, where the first level classification is correct, but the second level one is completely wrong.
When I've gone into the depths of the formula, the issue is that the Search function is returning the wrong value.
This appears to be a known issue: https://answers.microsoft.com/en-us/msoffice/forum/all/how-to-use-named-range-in-search-function/14c8c989-bed0-48f9-bce0-c0894571b557
Ideas welcome on workarounds/how to solve the problem.
Cheers Jon
Would you consider:
=MATCH("Apple",List)
and
=MATCH("Pear",List)
to return 1 and 2 respectively.
A couple of things in regards to your question:
The correct syntax for search is =SEARCH(find_text,within_text), so the correct formula would be =SEARCH("Pear",List).
The reason why you are getting the #Value is, because you are applying search to a range, but the function is only intended for cells.
The best ways to see if a value exists in a range are the countif and match function:
The countif function shows you how many times the a value is in a range:
The match function shows you in which row the the first value is: