I am trying to get a dedicated material table in excel. So we have a few products and these products require particular materials. I know how much and which materials go in particular products. I also know how much is sold in which year, now I want to calculate the required materials for these years. Because the productbase is large (>100), and thus >100 columns, I would like to use some lookup or index function to automate the multiplication.
As shown in the picture, I tried using a sumproduct, which was also explained in some other question on stackoverflow. This sumproduct should multiply all values obtained in one table with the corresponding values in the other. I feel that something is not right about my first two match functions (see picture again)
The code used:
=SUMPRODUCT(INDEX($B$19:$E$22;MATCH(B$2;$A$19:$A$22;0);MATCH(B$10;$B$18:$E$18;0));INDEX($B$3:$E$5;MATCH($A11;$A$3:$A$5;0);MATCH(TRUE;$B$3:$E$5>0;0)))
The image contains some extra info and explanation of the actual need
The reason that it needs a lookup or index is because the products in table 3 are always in another order than what is shown in table 1.
I would like to have this sumproduct as automated as possible, thank you in advance:)
You could try and adapt the below:
Formula in B11:
=SUM(INDEX($B:$B,MATCH($A11,$A$1:$A$5,0)):INDEX($E:$E,MATCH($A11,$A$1:$A$5,0))*TRANSPOSE(B$19:B$22))
Entered as array, CtrlShiftEnter
Drag right and down into matrix.
Side-note: Be sure to edit your question to include all relevant information, including your own atempted formula, as text. Way easier to copy paste sample data that has been formatted as markdown :)
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.
I'm not sure how to explain what I am trying to achieve so I will start with the data I am working with:
1) A table that lists IDs corresponding to Games. Each game has several IDs.
2) A table that lists IDs and $ Earned on those IDs.
In another table, I have the list of games and want to return the sum of $ Earned on those games:
Tables 1,2,3
I was trying to do this with a combination of a SUMIF and VLOOKUP formula but I can't seem to find a way to do that because the VLOOKUP returns a value rather than a range. What I want to do is sum a sum_range ($ earned) if the lookup value of the range (game corresponding to the code) is a match.
I could simply add a column to the second table that returns the game of that code with a VLOOKUP. But the problem is that this would need to be done in a very large number of sheets, and with each time the new data is received.
Hopefully that made sense and thank you in advance for any help I can get!
Cheers,
Maria
Well this may be a bit of a cheat. if you look at your game code, you are either looking for basketball or baseball. So we could do a sum if the code contains one of those words.
If case sensitivity is important
=SUMPRODUCT(--(ISNUMBER(FIND("Basketball",B2:B16)))*C2:C16)
or if case sensitivity is not important
=SUMPRODUCT(--(ISNUMBER(SEARCH("Basketball",B2:B16)))*C2:C16)
B2:B16 would be your code in table 2
C2:C16 would be your $ earned column in C2
The formula would be placed where the ? cell is beside big win Basketball.
updated option for keyword
So if you are not looking for just baseball or basketball, but the entire string of the key words that you are looking for the total for, you could use the following provided the words in table three form part of the code when the spaces are removed.
=SUMPRODUCT(--(ISNUMBER(FIND(SUBSTITUTE(B19," ",""),B2:B16)))*C2:C16)
or
=SUMPRODUCT(--(ISNUMBER(SEARCH(SUBSTITUTE(B19," ",""),B2:B16)))*C2:C16)
This assumes the keyword your are looking for in the code is in B19. The substitute function removes the spaces to match your code.
In the second table add a (hidden) column, where you perform a VLOOKUP in the first table of the Code, retrieving the Game name.
Now you have something to base your SUMIF on: the value in the additional, hidden column should match the Game you have in your summary.
I am an excel beginner and I would like to do the following.
Let row1= (a_1 a_2 a_3) and row2= (b_1 b_2 b_3).
I want excel to calculate the largest number among the products (a_1b_1, a_2b_2, a_3b_3).
It is very difficult to look up these things for I am not sure what kind of calculation I am doing and it is hard to explain.
Take a third column, C and enter formula in C1 as $A1*$B1. Pull it down vertically to all other rows so that row number gets incremented for each.
Then in the fourth column, use the formula MAX(C:C)
The following formula, array-entered, gives you the result of the largest number among the products:
{=MATCH(A1:C1*A2:C2)}
(provided your data is in A1:C2 in the form you presented it).
For explanations on how to insert array formula in excel see e.g. this microsoft link; in short, you type the formula without the curly brackets and confirm with CTRL+SHIFT+ENTER instead of only ENTER.
If you want to find where this couple of numbers is (in your case: which column), I would try this:
{=MATCH(MAX(A1:C1*A2:C2);A1:C1*A2:C2;0)}
(also array-entered).
you can do that, or make a pivot with the raw data and get the MAX/MIN/AVG, based on the pivot options. I tend to use that instead and then vlookup the ID to the pivot to get whatever aggregate you need.
I am trying to compare two different Excel (2010/xlsx) tables with related data to find matches. They would be on different sheets but in the same workbook (not that it should affect the problem).
I think the best route is some combination of sumproduct, match, and index... but I haven't been able to get them to work so far. I see the main question (cell G17) being solved by creating a subset of rows from Table 2 to compare against their corresponding data in Table 1 (index/match), then using arrays to do a multiple criteria selection to count how many match the criteria I chose (sumproduct).
I have played around with vlookup, countif(s), and sumif(s) but haven't seen a good way to apply them to this problem.
You can use SUMIF as a "quasi-lookup" like this
=SUMPRODUCT((file="doc")*(modified < SUMIF(user,creator,create)))
I'm not sure how to do it in a single cell as you've asked, but I would create an extra column in the second table which uses vlookup to find the created date, and another column containing whether or not the created date is greater than the modified date. Finally, you could use countif to combine them.
To be more concrete, in your example, I would put =vlookup(F3,A$3:D$5,2,FALSE) in cell I3, and =I3>H3 into cell J3, and expand both of these down. Then cell G17 could be given by =countif(J3:J5,TRUE).