SumIf with Wildcard - excel

I'm trying to use a wildcard and the SumIf function or a SumProduct Function. In one column I have different Transaction Descriptions. I want the function to give me all the totals for adjacent cells to cells containing a key word. I've tried the following formulas:
=SUMPRODUCT((ISNUMBER(SEARCH("Company",Sheet5!F2:F72)))*Sheet5!G3:G71)
=SUMIF(Sheet3!F:F,"*Company",Sheet3!G:G)
Neither will return a value.
My company descriptions vary, which is why I'm trying to use the wildcard. For example, sometimes the description in F is Company LLC - January, and sometimes its Company LLC - Parent Distribution, etc...I just need it to find all transactions with Company in the cell.
Thanks!

Here is a short example that you can adapt. It processes data in A1 through B5:
=SUMPRODUCT(--ISNUMBER(SEARCH("Company",A1:A5))*(B1:B5))

Related

Indirect index and match problem formula in different named tables

I have a cell where I want to get the tax% based on a criteria
Coming from "Taxes", depends on manufacturer country, year of release and car type
I've tried to use search and index and its not working at all, I need the cell to check values in the manufacturer country, year of release and car type use these inputs go to the Taxes sheet and get the value
Before I start, I should come clean and say I am an evangelist for the OFFSET() function, and a mortal foe of INDIRECT().
Let's assume that the number of vehicle types (TRUCKS, SEDANS, ....) is the same for each country, ie 8. (If its not then that can be worked around with a bit more effort). You could put this number in a cell somewhere and use it when you need the number of types.
Also, let's say the first column in your screenshot is column A. And that the cell A1 contains "China".
Let's say we are looking for the tax rate in 2009, for SEDANS in France.
Function 1:
=MATCH("France",$A:$A,0) will return 14 (if I have counted correctly)
... ie cell A14 contains the word "France".
On the assumption that the years are the same for all countries we can use any of the header rows to find the right column.
Function 2:
=MATCH(2009,$3:$3,0)-1 will return 8 I think.
If your years are just strings of text, then replace 2009 with "2009".
Because your Types are not in the same order in each table (why?) we need an extra step.
Function 3:
=MATCH("SEDANS",OFFSET($A$1,(Result of f1) -1 + 3,0,8,1),0) should return 3.
What is the maths in the OFFSET function? I need to go down (14-1) rows from cell A1 to get to "France". From there I need to go down another 3 rows to get to the first of the list of Types, and there are 8 types to search in. I'm then looking at a range of cells which is 8 rows x 1 column.
Now you can extract your tax rate, using
Function 4:
=INDEX(OFFSET($A$1,(Result of f1) -1+3,1,8,100),(Result of f3),(Result of f2))
(I've put 100 as I don't know how many columns of years you have. You could use something like =COUNTA($3:$3)-1 if there was nothing else in the 3rd row after the last date).
I would put the results of each function in a cell while you test this. Once you are happy that each step is working correctly you can nest all the various functions together, or alternatively just put some extra columns on the right hand side of your results table, which you can Hide if you want to.
EDITED: To add some $ on cell references to lock the "origin" of the data.
If your tax tables are real Tables, each NAME'd with the name of the respective country, you can use something like:
=VLOOKUP(H13,INDIRECT(H12),MATCH(TEXT(H14,"0"),INDIRECT(H12 & "[#Headers]"),0))
where
H12 contains the name of the country
H13 contains the Type of vehicle
H14 contains the Year
eg:
You'll need to adapt this to your real ranges, but this provides an approach.
I'd suggest using dropdown lists (from Data Validation) in H13:H14 in order to avoid typos.
If you want to avoid using Tables and also the volatile functions OFFSET and INDIRECT (because if you have a lot of volatile functions they can impair performance of your worksheet) you can try the non-volatile, but longer and more obscure:
=VLOOKUP($H$13,INDEX($A:$A,MATCH($H$12,$A:$A,0)):INDEX($D:$D,LOOKUP(2,1/($A:$A<>""),ROW($A:$A))),$H$14-2000,FALSE)
In the above, you'll have to make adjustments
Assumptions are:
The country name is above the relevant tax table
Tax table starts in Column A
Change references to Column A if it does not start there.
Change the reference to Column D to the last column of your tax table (or even further if you will be expanding it).
The Year columns are labelled the same for all countries (eg: consecutive years starting at 2002)
$H$14-2000 calculates the column argument for the VLOOKUP function.

Using VLOOKUP and not only match on first value

I'm trying to use VLOOKUP to match activities with product codes, but run into an issue since VLOOKUP always returns the first match. I did a mockup below to describe my issue. To the left, I have a table with activity names and product codes.
To the right, in column G, I want to, based on matching activity names in column F with activity names in column A, assign the activities product codes from column B.
When I use VLOOKUP, it only matches with the first activity name and give all the activities with the same name the same product codes. I need them to get different product codes even if they have the same name. I want my function to "take the next one" on the list, when the first one is taken.
Should I try to use another function to solve this? Is it impossible with VLOOKUP? My 'real' document has like 2000 rows, and the solutions I found on Youtube was not good to scale.
Thanks in advance. I'm new to here so if I should clarify my question in any way, feel free to tell me.
If the raw is around 2,000 rows, you can use a nested index match with helper columns.
Add a rank in column C with the formula =COUNTIF(A2:$A$2,A2)
Then apply the same ranking in your output part as well (Ensure Activity Name is sorted so that the formula works), Output rank formula =IF(J2=J1,I1+1,1)
Formula that lists out the Product Code {=INDEX($B$2:$B$3190,MATCH(I2,IF($A$2:$A$3190=J2,$C$2:$C$3190),0))}
This is an array formula, you get the curly brackets by hitting control+shift+Enter instead of just Enter upon keying in the formula
If you are using excel 365, you can use UNIQUE formula.
=UNIQUE(A2:B18)

How to total a column in a table based on filter criteria from two other columns in excel

I have the following Table as an example:
Name Task Amount
Jennifer Sing 10
Tom Dance 15
Joe Jump 72
Mandy Scream 10
And supporting lists:
Names Tasks
Jennifer Dance
Joe Sing
Jump
I need to find the total of the sum of amounts where Name is in the Names list AND Task is in the Tasks list. In other words, if the person AND the task are in the list of relevant people and tasks, total their amount.
So, for example, the total would be 10+72=82.
I have tried to name the ranges of the criteria lists as RelevantNamesList and RelevantTasksLists, and the input table columns as Names and Tasks and Hours, and then using sumif, however I am not even able to get it to work with a single condition.
=SUMIF( Names, ( -- ( ISTEXT(VLOOKUP( Names, RelevantNamesList, 1, FALSE))) ), Amounts)
The actual result I get using the above code is a 0, which is obviously not correct. I have also tried to use sumproduct, with no success. I am beginning to think that I wont be able to use this without helper columns.
Is there a way to do this without helper columns?
Thanks in advance!
Jacqueline
Give this a try:
=SUMPRODUCT((COUNTIF(<Names To Lookup>,<All Names List>)>0)*(COUNTIF(<Tasks To Lookup>,<All Tasks List>)>0)*<All Amounts List>)
So if you had a data setup like this:
Then the formula would be:
=SUMPRODUCT((COUNTIF($E$2:$E$3,$A$2:$A$5)>0)*(COUNTIF($F$2:$F$4,$B$2:$B$5)>0)*$C$2:$C$5)
EDIT:
Per comment, the lookup criteria could be partial matches. For example, the name in the list is Ms Jennifer Keim and what's being looked up would be Jennifer. In order to accomodate this, you'd need to switch tactics to the DSUM function. This means that you'll need to alter how you setup the criteria.
There are two ways to do this, the first is to create a row for each set of criteria you want, and the second is to have the limited list like you originally have and then setup criteria formulas you then feed into the DSUM. Here's the data setup for the first scenario (note that the lookup headers must exactly match the table headers and that you're putting the wildcards for partial match directly in the criteria):
The DSUM formula in this scenario is:
=DSUM($A$1:$C$5,"Amount",$E$1:$F$7)
For the second scenario, we setup the limited criteria like you originally had it, but now we need helper formulas to feed into the DSUM. Note that the helper formula headers must not be in your original datatable (here i've added "Check" to the end of the header names as an example):
The formulas need to reference the first cell in your datatable and perform the check against your criteria. The DSUM formula will expand that formula's check against every row, so we only need this for the first row to establish the logic that DSUM will use. Here are the two formulas for NameCheck (cell H2 in this example) and TaskCheck (I2). We are using these formulas to allow for partial matches when looking up the criteria against the datatable:
NameCheck: =SUMPRODUCT(--(LEN(SUBSTITUTE(A2,$E$2:$E$3,""))<LEN(A2)))
TaskCheck: =SUMPRODUCT(--(LEN(SUBSTITUTE(B2,$F$2:$F$4,""))<LEN(B2)))
Now the DSUM criteria argument references those formula cells and becomes:
=DSUM($A$1:$C$5,"Amount",$H$1:$I$2)
For further reading and information regarding the DSUM formula, Contextures has a great explanatory article with an example workbook you can download and experiment with: https://contexturesblog.com/archives/2012/11/15/dsum-and-excel-tables-sum-with-multiple-criteria/

Excel VLOOKUP with multiple possible options in table array

I have two lists, the first is a set of users. The second list contains different encounter dates for these users.
I need to identify the date that is within 10 days of the "Renew Date" [Column C], but not before. With Member 1 this would be row 3 1/8/2017. With Member 2 this would be row 6, 1/21/2017.
Now using a VLOOKUP which the user before me who managed this spreadsheet obviously isn't viable as it's simply going to pickup the first date that has a matching Member ID. Is there a way to do this in Excel at all?
I have included a link to a sample file and a screenshoit of the sample data.
https://drive.google.com/file/d/0B5kjsJZFrUgFcUFTNFBzQzN4cm8/view?usp=sharing
To avoid the slowness and complexities of array formulas, you can try with SUMIFS but the problem is that if you have more than one match, it will add them, not return the first match. The sum will look like an aberration. Will work however if you are guaranateed that you have only one match in the data.
An alternative is also to use AVERAGEIFS, which, in case of multiple matches, will give you their average and it will look like a valid date and a good result. Enter this formula in D2 and fill down the column:
D2:
=AVERAGEIFS(G:G,F:F,A2,G:G,">="&C2,G:G,"<="&C2+10)
and don't forget to format column D as Date.
Try this
=SUMPRODUCT($G$2:$G$7,--($F$2:$F$7=A2),--($G$2:$G$7<=C2+10),--($G$2:$G$7>C2))
Format the result as date. See screenshot (my system uses DMY order)
Don't use whole column references with this formula. It will slow down the workbook.

Excel countif does not look up a different sheet

I am hoping someone can help with this Excel 2016 issue. I have done extensive searching on the net and believe I have found the formula to address my requirements. Before sharing the formula, let me explain my need.
I am creating a budget spreadsheet. There is currently two sheets in the spreadsheet. sheet1 contains data for categories and keywords. Column A contains different categories like Car Fule, Salary, Bank Fee, etc. Column B contains keywords to be search for within the transaction description. An example could be:
car fule | Mobile
Sheet2 contains all the transaction data. All the columns other then column c isn't relevant for this issue. An example of a transaction description could be: "EXP mobile Hobbitville 2221 MiddleEarth".
I am trying to create a formula that does a search in the defined cell for column c, against the keywords found in sheet` column b. Then once a match is found, perform a indirect function call to give the category of the transaction. I cannot get the initial search to work.
Formula that should work is:
=countif(c2,"*"&sheet1!$b$1:$b$85&"*")
This always gives a value of 0 saying it hasn't been found. I am using ctrl shift enter and ctrl enter to make the an array formula. If I press f9, I get all the values defined from sheet 1 as {0, 0, ...} (or something like that) which is what I expect. In that array, I should get at least one element as a '1' (true value). If I can fix this part of the formula or find a better method, then I can build the rest of the formula. Any one with ideas?
This is the COUNTIF syntax,
COUNTIF(range, criteria)
It should be the other way around,
=COUNTIF(C:C,"*"&Sheet1!$B1&"*")
Let me know if its not working

Resources