Good evening all,
I want to do a sumifs() but the two columns do not always have the exact same values. However, the first 8 characters would always match in both columns. For example the value I wish to look up is "00123456 - Nice Salad". The data I wish to search in sits in Column A with value to return in Column B.
I know I can use the left() function on the value to lookup but I am unsure how best to search against just the first 8 characters in column A. I would like the formula to return the number 6 from column B in this example.
Current formula is as follows: =sumifs(left(00123456 - Nice Salad,8),A:A,B:B)
I hope this all makes sense and any help is appreciated.
Many thanks, Alan.
Screenshot/this sheet refer:
One way is with a regular sum equation:
=SUM(1*(LEFT(A2:A4,8)=E2)*(B2:B4))
However, this can be computationally intensive (i.e. if you have plenty of data/rows to evaluate). The better, in my view, is simply a sumifs with wildcard '*', i.e.:
=SUMIFS(B2:B4,A2:A4,E2&"*")
Hi and thanks very much for taking the time to read/respond.
I'm struggling with trying to adapt a very advance formula given by tigeravatar here: tigeravatar
I have an almost identical issue, but have the following possible states:
A, B, C, D, and corresponding levels of priority.
In a given range, multiple entries in any of these four categories could be made. But I need to return only the highest value regardless of all other entries.
Here's the original formula.
=INDEX({"","D","C","B","A"},MATCH(SUMPRODUCT({4,3,2,1},--(COUNTIF('Sheet 002'!E29:E32,{"A","B","C","D"})>0)),{0,1,2,3,4}))
The only problem being that in the formula above if B and C co-occur it displays A, and if B and C only display if they occur in isolation.
Thanks in advance for your and any inputs you're willing to share!
If you were willing to have a helper column, you could convert the letters to numbers using =CODE(). This column can then be ranked by taking the minimum (A=65, B=66, etc.) Note that CODE() is case-sensitive. You can find the highest ranking letter by using a formula like this:
=INDEX(E29:E32,MATCH(MIN(F29:F32),F29:F32,0))
Screenshot
I have date column H, and values in K, and I want to find the sum of the VALUES in K --if H is today.
I tried =COUNTIFS(K:K,"<>",H:H,">="&TODAY())
which gives me the number of entries today, but NOT the sum of their values!
Also, when searching I found some suggestions talking about greater/lesser than today, but I'm looking to compute Today only!
Here is some reading material about SumIfs ...
=SUMIFS(K:K,H:H,TODAY())
I prefer SUMPRODUCT for this.
= SUMPRODUCT(K:K,(H:H=TODAY())+0)
I recommend narrowing down the full column ranges to where ever your data actually ends (e.g. if you have 100 rows of data, change K:K to K1:K100).
=SUMIFS(K2:K500,H2:H500,TODAY())
First column is text labels, therefore not included.
I have a (large) array of data in Excel of which I need to compute the average value of certain values in one column, based on the values of another column. For example, here's a snippet of my data:
So specifically, I want to take the average of the F635 mean values corresponding with Row values of 1. To take it a step further, I want this to continue to Row values of 2, Row values of 3 etc.
I'm not familiar with how to run code in Excel but have attempted to solve this by using the following:
=IF($C = "1", AVERAGE($D:$D), "")
which (to my understanding) can be interpreted as "if the values (anywhere) in column C are equal to 1, then take the average of the corresponding values in column D."
Of course, as I try this I get a formula error from Excel.
Any guidance would be incredibly appreciated. Thanks in advance.
For more complicated cases, I would use an array-formula. This one is simple enough for the AVERAGEIF formula. For instance =AVERAGEIF(A1:A23;1;B1:B23)
Array-formula allows for more elaborate ifs. To replicate the above, you could do =SUM(IF($A$1:$A$23=1;$B$1:$B$23;0))/COUNT(IF($A$1:$A$23=1;$B$1:$B$23;0)).
Looks like more work but you can create extremely elaborate if-statements. Instead of hitting ENTER, do CTRL-ENTER when entering the formula. Use * between criteria to replicate AND or + for OR. Example: SUM(IF(($A$1:$A$23="apple")*($B$1:$B$23="green");$C$1:$C$23;0)) tallies values for green apples in c1:c23.
Your sample data includes three columns with potential ifs so my guess is that you're going to need array formulas at some point.
Excel already has a builtin function for exactly this use; AVERAGEIF().
=AVERAGEIF(C:C,1,D:D)
I have a spreadsheet with data in multiple catagories, e.g. Pet (Dog, Cat, Rabbit), gender (M,F), mode of transport(Car,Bike,Skateboard). For each individual, these can either be true or false. I want to count the number of individuals with a particular combination of pet, gender, mode of transport. I want this to be automatic, so I can specify the gender, pet, mode of transport in cells and the formula counts based on these values.
e.g. How many people are Male, have a Dog and have a Bike? In this case, Male, Dog and Bike need to be read from cells in the spreadsheet.
I have a formula which uses indirect and offset to select columns but can't help but think there must be a better way.
Here's an example which makes it far clearer than my wordy explanation above. Thanks in advance for your help.
Is there a way of representing my data that's better suited to make this counting easier?
Google Drive Link to Excel file
A very valid - I don't download random files from the internet comment:
Here's a csv:
Name,Dog,Cat,Rabbit,Male,Female,Car,Bike,Skateboard
Alice,TRUE,FALSE,FALSE,FALSE,TRUE,FALSE,TRUE,FALSE
Bob,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE
Chris,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE
Dave,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,TRUE
Ellie,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE
Frank,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE
Gerald,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE
Also the formula I used was:
=COUNTIFS( OFFSET(INDIRECT("R3C"&MATCH(L3,Headings,0),FALSE),0,0,numberOfPeople,1),TRUE,
OFFSET(INDIRECT("R3C"&MATCH(M3,Headings,0),FALSE),0,0,numberOfPeople,1),TRUE,
OFFSET(INDIRECT("R3C"&MATCH(N3,Headings,0),FALSE),0,0,numberOfPeople,1),TRUE)
Where numberOfPeople is a reference to a cell that counted the number of entries. And headings is a reference to the column headings of the table.
OFFSET and INDIRECT are volatile functions, in that they will recalculate every time excel calculates regardless if the underlying data has changed or not.
I prefer to use INDEX to return a range.
INDEX takes 3 criteria. INDEX(range,row,column). By putting 0 in the row criterion it will return the full column.
so using MATCH to find the correct column and 0 for row we get the correct column returned.
=COUNTIFS(INDEX(A:I,0,MATCH($K$2,1:1,0)),TRUE,INDEX(A:I,0,MATCH($K$3,1:1,0)),TRUE,INDEX(A:I,0,MATCH($K$4,1:1,0)),TRUE)
It is pretty easy if you use the COUNTIFS formula combined with several IF statements. Here is what should work (put in "O3" and copy down):
=COUNTIFS(IF($L3=F$2,$F$3:$F$9,$G$3:$G$9),TRUE,IF($M3=C$2,$C$3:$C$9,IF($M3=D$2,$D$3:$D$9,$E$3:$E$9)),TRUE,IF($N3=H$2,$H$3:$H$9,IF($N3=I$2,$I$3:$I$9,$J$3:$J$9)),TRUE)
This compares the given values for your categories in the inner IF statements and returns the corresponding columns to check for TRUE. What COUNTIFS does then is to count all rows where the criteria is TRUE for all given criterias. You can also expand your categories by adding more inner IF statements to return corresponding rows.
It would not be quite easy to change your data representation due to the fact that you can have multiple values for one row. You would have to split data with multiple values into multiple rows. Here is an example:
You could then just use the following formula:
=COUNTIFS($D$3:$D$14,$L3,$C$3:$C$14,$M3,$E$3:$E$14,$N3)
Having given Gender in "L3", given Pet in "M3", given Transportation in "N3".
If you have further questions, leave a comment.