I'm looking for a formula which lets me search for matches between two columns, and where a match is found, add the associated value from a 3rd column.
Example
If a fruit in column B matches any of the values in Column A, add the associated value from Column C. Here you have 2 grapefruit matches ($2) and 2 orange matches ($.5) so you get $5.
Is there a formula to do this automatically? Huge thanks for any help!
A simple version is
=sum(filter(C2:C8, match(B2:B8, A2:A4, 0)))
which looks up each element of B2:B8 in the range A2:A4, and if there is a match, includes the corresponding entry from C in the sum.
If you expect the entries in column A to grow (so they won't always stay A2:A4), the following may be preferable:
=sum(filter(C2:C8, match(B2:B8, filter(A2:A, len(A2:A)), 0)))
Here the fixed range A2:A4 is replaced by the output of a filter, which returns all nonempty cell in A2:A.
Related
As you'll see in my sample sheet, I've already found the match between two columns (C and D) and put the results in E. So these values correspond to a value from C, but are in a different order.
Now I want the values from column A, but I need for the formula to match E's value to the correct row in column C first to get the correct corresponding subject in column A.
LMK if my description needs improvement, I just rewrote it about 3 times.
I think this does what you want. There's no index function for array so you have to reconstruct a vlookup.
=filter(If(E2:E="","",vlookup(E2:E,{C:C,A:A},2,false)),not(isblank(A2:A)))
try:
=INDEX(IFNA(VLOOKUP(E2:E, {C:C, A:A}, 2, )))
I am trying to do a partial match of Products (Column B) to DB (Column H). Column B however has many partial names within the cell. The entirety of Column H needs to be searched for a partial match of Column B, if a match is found then the cell name from column H needs to be input into column C.
Link to sample Google sheet: https://docs.google.com/spreadsheets/d/1ZvIbZQ9zsLd6w1uGgSbQ3v-QFebMYrlQfvdsLCfEwAg/edit?usp=sharing
Any advice on how to do this would be appreciated.
In order to look for a substring that would correspond to all the cell values from H2:H70 in B2 (and the subsequent values of the column B) you will be wanting to use the function REGEXMATCH that compares a text (in the case below B2) with a regular expressing (each of the values from H2:H70). If it finds a match then it returns the value of column H by using the IF function and if it doesnt it returns empty.
As we are comparing the range H2:H70 to B2 this will return an array of possible matches or not matches (emtpy after the IF) and therefore this array must be handled with ARRAYFORMULA.
Then we are using QUERY to only return the array values that are not empty. This will leave us with an array of values of just the actual matches found (in case there are more than one). As I imagined that you want all the matches in a single cell I am taking all the matches array values and joining them in a single array separated by a space using TEXTJOIN.
Finally, I am using IFERROR to return empty in case no matches were found.
=IFERROR(TEXTJOIN(" ",TRUE,QUERY(ARRAYFORMULA(IF(REGEXMATCH(B2, $H$1:$H$70),$H$1:$H$70,"")),"where Col1 is not null")))
Ok, this is the updated linkI have multiple criteria to look through in my arrayformula(index(match())). The first two are simple as they reference the row the formula is calculating on. The last conditional I have is to find the highest occurrence in a given range, but ONLY if the other conditions are met...something like a filtered maxifs..any ideas?
Here is my code in column P =iferror(ArrayFormula(index($F:$F,match(1,("Fee Taken"=$C:$C)*(H12=$H:$H)(maxifs($M:$M,$H:$H,H2,$C:$C,"Fee Taken"),0))),""))
The result that I would like is to return from column F if the name matches that rows name, the transaction type is "Fee Taken" from column C, and THEN if those conditions are true I want it to find the max value from column M based on those two criterias and return the column F value for that max value row..
Ive attached some pictues to show my data.
The last part of the Match function where I have the Maxifs equaling to eachother is where I am confused; my thoughts were to see if the maxifs for the item in Column "M" can be used as a criteria..but I do not think so....I only want the highest occurence F:F if both conditions are met and it is the highest value for both those criteria in column M..
Please let me know if you need anymore info..Thanks![
Working formula will be:
=ArrayFormula(index($F:$F,match(1,--(M:M=(maxifs($M:$M,$H:$H,H2,$C:$C,"Fee Taken"))),0)))
Below is an example of the values I'm trying to add. My goal is not to use the filter formula for every line again. This is because it takes a lot of resources from the processing power that google sheets uses.
The words in the left list below occur several times in combination with a certain number. I want to have a unique list as shown on the right where the values from the left row add up when the words are equal (without using a filter formula for each line).
This formula
=arrayformula(vlookup(A:A, A:B, 2, FALSE)))
comes very close, but returns only one value even though there are multiple matches. I want all values that matches returned.
try:
=QUERY(A:B, "select A,sum(B) where A is not null group by A label sum(B)'summed'", 1)
I'm trying to get the sum of all items in column F:F when Column J:J = "Channel"and Column K:K = "Country"
=DSUM(Sheet1!$A$1:$K$142,Sheet1!$F$2:$F$142,{{Sheet1!K:K;"Channel"},{Sheet1!L:L;"Country"}})
The above query returns a 0 when it should return a 7.
Try:
=DSUM(Sheet1!$A$1:$L$142, Sheet1!$F$1, {{Sheet1!$K$1; "Channel"}, {Sheet1!$L$1; "Country"}})
Notice changes about the parameters:
Sheet1!$A$1:$L$142 column L:L should be included if you want to use it in your criteria.
Second parameter just needs a column name (Sheet1!$F$1) or its number (6). No need to place the whole range there.
You need to have a two strings range for criteria: first one with the column name, second with the criteria for that column. You set before the whole column K:K and L:L and placed a string to match at the bottom. Only the first tow rows were used, so you criteria was actually like this: kolumn K:K should be like the value in K2 and column L:L like the value in L2 (but this one didn't actually worked as this column was not a part of your table (the 1st parameter)).
Or you can use SUMIFS:
=SUMIFS(Sheet1!$F$2:$F$142, Sheet1!$K$2:$K$142, "Channel", Sheet1!$L$2:$L$142, "Country")
Or if you need to sum the whole column (not just down to 142 row):
=SUMIFS(Sheet1!$F:$F, Sheet1!$K:$K, "Channel", Sheet1!$L:$L, "Country")
Here's a basic proof-of-concept.
Count all vegetables
Answer: 18
Formula: =DSUM(A4:D10,"Qty",{"Category";"Vegetable"})
Count all vegetables at Safeway
Answer: 10
Formula: =DSUM(A4:D10,"Qty",{{"Category";"Vegetable"},{"Store";"Safeway"}})