using index match with sum if - excel

I need to link up a sumif() with an index match (i'm guessing here) but don't really know where to start.
Basically i a table with different classes of pets, their species and quantity. there are 3 stores. I need an output where i can get the quantity of each species from each store dynamically.
data table:
"A1" Pet Stores
Species Class a b c
cat Fluffy1 1 0 0
cat Fluffy2 3 0 0
cat Fluffy3 5 7 1
cat Fluffy4 6 0 7
dog Barky1 7 6 9
dog Barky2 1 3 9
dog Barky3 0 2 8
dog Barky4 0 2 3
fish Swimmy1 0 0 0
fish Swimmy2 1 3 0
fish Swimmy3 0 2 3
fish Swimmy4 0 0 0
Output:
Pet Store a <--change this
cat 15 <--output
dog 8 <--output
fish 1 <--output
right now my formula for "cat" is =SUMIF($A$3:$A$14,A17,$C$3:$C$14). however, it only looks down the 1 column that i've set. how do i change it such that it searches for the "Pet Store" and returns sum of the respective column?

How about this:
Formula in cell H3 copied down is
=SUMIF($A$2:$A$13,G3,INDEX($C$2:$E$13,,MATCH(H$2,$C$1:$E$1,0)))

Slightly shorter that #teylyn's version:
=SUMIF(A$2:A$13,A16,OFFSET(C$2:C$13,,CODE(B$15)-97))
but less versatile as it relies on the shop names being coded (which however is as in the example and makes sense for column label purposes):
However my preference would be for a PivotTable:

Related

Is it possible to create a formula that would sum multiple columns by looking up two parameters?

The question may sound very odd, so let me explain.
E.g. I have a table that looks like this:
1 2 3 3
Soda 1 2 1 0
Beer 2 0 0 0
Beer 2 1 2 2
Soda 0 2 0 2
I would like to sum each "drink number" for every category, like this:
1 2 3
Soda 1 4 3
Beer 4 1 4
I have used the IFS and SUMIF formula sequence for this (where B$1 = "Column number",$A2 = "Drink name", rest is just columns corresponding to value locations):
=IFS(B$1=“1”,SUMIF($A$2:$A$5,$A2,$B$2:$B$5),B$1=“2”,SUMIF($A$2:$A$5,$A2,$C$2:$C$5),B$1=“3”,sum(SUMIF($A$2:$A$5,$A2,$D$2:$D$5),SUMIF($A$2:$A$5,$A2,$E$2:$E$5)))
But it is very robust, and needs to be changed manually if the initial table is changed.
I would like to make my formula adaptable to changes. Say, it "looks up" row and column values and sums up every column values by them. For example, if one more column "2" is added, and "Beer" is changed to "Milk" (but the "column length" remains the same);
1 2 2 3 3
Soda 1 2 1 1 0
Milk 2 0 1 0 0
Milk 2 1 0 2 2
Soda 0 2 1 0 2
The formula automatically adjusts to this change, and calculate new sum:
1 2 3
Soda 1 6 3
Milk 4 2 4
Is it possible to create such formula? Because I'm not even sure if something like this can be done with basic Excel formulas. Thank you beforehand.
Yes. For example:
=SUMPRODUCT(($A$2:$A$5=$G2)*($B$1:$E$1=H$1),$B$2:$E$5)
where G2 has Soda and H1 has 1. Then copy across and down (assuming Beer in G3 and 2, 3 in I1:J1)

Count rows where two values appear together

My data are in MS Excel:
Col A Col B Col C Col D
1 amy john bob andy
2 andy mel amy john
3 max andy jim bob
4 wil steve andy amy
So, in 4x4 table there are 9 different values.
I need to create table to find how many times each PAIR is occurring in the same ROW. Something like this:
amy andy bob jim john max mel steve will
amy 0
andy 3 0
bob 1 2 0
jim 0 1 1 0
john 2 2 1 0 0
max 0 1 1 1 0 0
mel 1 1 0 0 1 0 0
steve 1 1 0 0 0 0 0 0
will 1 1 0 0 0 0 0 1 0
And I have no clue how to do it...
To reiterate: no duplicated values in each row, each row has unique values, each value in separate cell, so there are column with values and within column values can duplicate.
Any help will be much appreciated!
Assuming your data is in A5:D8 I proceeded like this -
created a helper column with the formula (copied downwards)
=A5&"-"&B5&"-"&C5&"-"&D5
Named this helper column as helper (named range)
listed down and across the unique combinations of names in H4:P4 (across) and G5:G13 (down)
enter this formula in H5 and copy it both downwards and across to fill all 9x9 matrix
=IF($G5=H$4,0,COUNTIFS(helper,"*"&$G5&"*",helper,"*"&H$4&"*"))
Your desired matrix is ready
A detailed blog is available on web for this.

find coordinates of a job number in one table and then find the numbers in matching coordinates in another table and sum those all up

i have 2 different equally sized tables in excel. one table has job numbers, the other table has hours worked, i want to search how many hours in total were spent on each job
for example
------hours---------------job #
m t w th f s s --- | --- m t w th f s s
8 8 6 8 8 0 0 --- | --- 1 1 2 5 4 0 0
8 8 8 8 7 0 0 --- | --- 2 2 5 4 1 0 0
What would a formula look like to find the sum of hours spent working on job #5?
I import this data from google forms and I don't think I can change the format too much.
thanks
You could try a simple SUMIF:
=SUMIF(I3:O4,B6,A3:G4)
Changing the value of B6 to 5 will yield 16 hours in B7.
Here's a simplified example using a smaller set of data:
Enter formula in C10 and fill down
You can use SUMPRODUCT too:
=SUMPRODUCT(--($K$2:$Q$3=$I$7);$A$2:$G$3)

Group by name and count unique values

I have an Excel file like this, where column A and B are given. I want to add column C and D that represent days. D is pretty easy, because it is always one day. C is tricky, because I want to count only "unique" days, where a branch can be one day maximum, where D counts all days.
A B C D
Row Name Branch Unique Overall
1 Jack Health 1 1
2 Jack Health 0 1
3 Jack Food 1 1
4 Jolie Tech 1 1
5 Jolie Food 1 1
6 Jolie Tech 0 1
7 Jolie Health 1 1
I need column C and D for a pivot table like this:
Branch Unique Overall
Health 2 3
Food 2 2
Tech 1 2
I also could add names as a sub position.
Branch Unique Overall
Health 2 3
-Jack 1 2
-Jolie 1 1
Food 2 2
-Jack 1 1
-Jolie 1 1
Tech 1 2
-Jolie 1 2
But that´s something, that can be done after preparing the data and what comes with the program anyway. So how can I design a formula that counts only unique branches for a data set of hundreds of rows?
Thank you!
In C2 put:
=--(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1)
Then copy down

Excel how to check if a row has any other values and return the index

I have this big table where the first column is the person. The second column is something they all have. And then there are different columns for possible other things they could have.
For example :
Person apples pears bananas oranges
Luc 7 0 0 0
Julia 10 0 0 2
Maria 8 0 0 0
Lena 15 0 3 0
Tina 2 1 0 1
I know for a fact that everybody eats apples, but i would like to know if people eat other things also and wich thing those are
The result should be
Person appels pears bananas oranges result
Luc 7 0 0 0 0
Julia 10 0 0 2 oranges
Maria 8 0 0 0 0
Lena 15 0 3 0 bananas
Tina 2 1 0 1 pears, oranges
The last column doesn't have to be the name of the fruit, I would be happy if I had the column number. I tried HLOOKUP, but this doesn't work . Or maybe I don't use the right lookup_value ? I use > 0 as lookup_value.
Can somebody please help me ?
One solution: Create "dummy variables" (formatted with text instead of {0,1} values) that are only populated for fruits actually consumed (N>0), and then concatenate in the results column:
ID Apples Pears Bananas Oranges d_apples d_pears d_bananas d_oranges result
Luc 7 0 0 0 Apples
Julia 10 0 0 2 Apples Oranges Oranges
Maria 8 0 0 0 Apples
Lena 15 0 3 0 Apples Bananas Bananas
Tina 2 1 0 1 Apples Pears Oranges Pears Oranges
In the d_apples column, I've entered =IF(B2>0, B$1, "") and filled this across the d_ columns.
In the results column, I've entered =TRIM(CONCATENATE(G2, " ", H2, " ", I2)).
The TRIM() function removes the extra blank spaces between words for fruits not eaten. Note of course that this doesn't add commas between words, and adding commas to the CONCATENATE() function will yield something like , Bananas,.
If you want the column numbers, you can change B$1 in the IF() function to COLUMN(B$1).

Resources