How do I sum several rows by category? (EXCEL) - excel

I have created an excel sheet to have an overview over costs in my projects, however, I also need an overview of costs per category in my projects. I googled it and tried to find examples online, however, it only returns a value of 0, which shouldn't be the case. Can anyone help me? The sheet looks like below.
I am going by the SUMIF function to group by category but my excel sheet is a bit more complex than that so I tried to adjust it accordingly as seen in the code below. No matter what I do it either returns an error or 0.
=IF(B12=B8;"";SUMIF(B12:B39;B12;J12:BE39))
In the formula above I am trying to sum the costs of a category that could be written in B12, for example, Software development. For confidential reasons, I cannot show the actual filled out excel sheet.

sumif does not work with summing multiple columns. Instead use a sumproduct statement instead like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$BE$39)))
A detailed explanation to how this works can be found here
Edit:
I sense a follow up question coming, how to skip certain columns. Because as you have set it up now, it will count the entire range from J12 to BE39, in which you have both forecast costs and actual costs. I guess this is to compare the costs to what was projected and what the actual costs are. Right now it will count both the projected and actual cost, doubling up. To prevent this you can enter every second column separated by a + like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$J$39+$L$12:$L$39+$N$12:$N$39)))
Also I have added $ signs to all non-changing values so it will work when dragging down the fill handle on the formula to populate the below cells.

Related

Is there a way to count the value of a cell under the criteria in Excel?

I've been toying with this problem for some time but no matter how hard I try, I can't wrap my head around the syntax of a command.
Screenshot of Spreadsheet:
First thing's first. The layout of this spreadsheet can't be changed in any way, making this problem a whole lot more difficult to solve. I've added a screenshot above of what the spreadsheet looks like at the moment. It is currently just a test-sheet as the master-sheet is having real data inputted into it.
So the first problem is searching the array "D:H" for the shot listed in the "I" column. For example, I want to count how many times "Vodka" appears in the array (D:H).
The second problem is I then want to sum each number contained in the cell below the criteria. Following the same example, given the criteria "Vodka" (I4), I want to be able to sum all of the cells under any cell containing the word "Vodka".
The third problem is then to multiply it by the "Amount Sold". Once again, following the same example, I would multiply it by the cells "C5" and "C9" as both of the cocktails have a shot of vodka in them.
The last problem really wraps it all up in a tight little bow. All of this will need to be adaptable to adding, removing and changing cocktails to this list, as well as the shots that are in them and the shots that are being searched.
Again, this is all test information as I don't feel as though I should be putting out anything involving my workplace.
Any help on this would be greatly appreciated.
Count amount of vodka in D:H
=COUNTIF(D4:H13, "Vodka")
Sum of all Vodka
=SUMIF(D5:H5,"Vodka", D4:H4)
Instead of Hard-coding "Vodka" in the cell you should use reference to the cells. This makes expanding the table easier
If you have the value the last multiplication is no problem.

Count over 2 dimensions

I am using excel 365.
I want to get aggregated for each product how often it is used by the departments.
I tried =COUNTIFS($B$2:$E$18;$I$2) on the times, however I do not know how to get the products?
Any suggestions?
It is truly complicated. My solution made it even more complicated, since it accounts for the number of departments (assuming that's the only data in the entirety of row 1) and products (assuming that's the only data in the entirety of column A) and any number of data introduced, also assuming the fixed placement of your calculations as shown in the example picture. Here's the formula you need in I3:
=COUNTIF(INDIRECT("R"&MATCH($H3,$A:$A,0)&"C2",0):INDIRECT("R"&LOOKUP(2,1/($A$2:INDIRECT("A"&COUNTA($A:$A)+1)=$H3),SEQUENCE(COUNTA($A:$A),1,2))&"C"&COUNTA($1:$1)+1,0),I$2)
You need to drag it all over the calculation area. I wanted to do a single cell spill array formula, but I don't think it's even possible right now due to its limitations (it generates the array first, and spills afterwards, making it static).

How can I multiply lookup values from two different tables and then sum them in just one cell?

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 :)

Lookup Job Code, return column header if cell has text

I'm looking for a little bit of help learning about how to use vlookup and iferror formulas together.
I am working as a licensing specialist within the insurance industry. My job requires that I frequently access more than a dozen spreadsheets that are emailed to us on a weekly basis from our clients. I am working to develop tools that allow us to consolidate that information on-demand to be able to run reports. I'm having no trouble using the VLookup function to pull data from various spreadsheets using an unique identifier. I do need some help, however, with a trickier formula.
I have put together a spreadsheet that allows me to put in the ID of the representative and it returns various bits of information, such as their name, license numbers, job codes, etc. Now I need to come up with a formula that takes the value returned in the job code field and searches another spreadsheet to return what training they are required to complete based on their job code. This spreadsheet is about 2000 rows, and is formatted with the training names spanning across the top row, job codes listed in column "A" and the word "yes" in each column that matches a training that the job code is required to take.
It looks like this: https://i.imgur.com/71COmfF.png
I need the formula in my reports spreadsheet to lookup the job code using VLookup and then return the column header if the cell has text.
The data will be loaded into this spreadsheet: https://i.imgur.com/2CyFURt.png
Here is the Vlookup formula I am using to get the job code:
=VLOOKUP(B3,'.\[Weekly_HR_Report_040615.xlsx]HR'!$A:$Q,10,FALSE)
How can I pair that same kind of formula with something like an IfError formula to return the column header if there is a "Yes" in the cell of the row that matches their job code?
I know that I can work through it as an array using VBA, but I would prefer to just place a formula in each cell so that I can pass this spreadsheet to another college when I move to a different role in the future and they won't struggle too much with adding to it.
Thanks for any help that you might be able to provide! I really appreciate it!
I would use INDEX and MATCH to cross reference and retrieve the titles where applicable:
=IF(INDEX('JobCode_Training.xlsx'!$A$1:$H$6,MATCH($H$5,'JobCode_Training.xlsx'!$A:$A,0),2)="Yes",INDEX('JobCode_Training.xlsx'!$A$1:$H$6,1,2),"")
=IF(INDEX('JobCode_Training.xlsx'!$A$1:$H$6,MATCH($H$5,'JobCode_Training.xlsx'!$A:$A,0),3)="Yes",INDEX('JobCode_Training.xlsx'!$A$1:$H$6,1,3),"")
=IF(INDEX('JobCode_Training.xlsx'!$A$1:$H$6,MATCH($H$5,'JobCode_Training.xlsx'!$A:$A,0),4)="Yes",INDEX('JobCode_Training.xlsx'!$A$1:$H$6,1,4),"")
etc.
I wasn't sure what your reference table is saved as, so you'll need to replace 'JobCode_Training.xlsx'! with whatever the correct path is.
Since you have multiple trainings that can apply to each jobcode, you'll either need to have multiple cells for the results, or you can concatenate them into one.
The following article from excelvlookuphelp.com answers your question I believe...
The Problem
You might be expecting that not all of your search values are going to return something from the search table. Instead of the formula returning #N/A you’d like the result to look different when your vlookup value isn’t found (either blank or an indicator to show that the value hasn’t been found or a zero if you’re wanting to do maths with the results).
The Solution
You can use the iferror function.
It works like this
= iferror (YourVlookupFormula, WhatToSayInsteadOf#N/A)
Here’s an example
=iferror(vlookup(D3,A:C,3,false), “No Value Found”)
Or if you would rather it was just blank then instead of having No Value Found, just have the two sets of inverted commas, like this
=iferror(vlookup(D3,A:C,3,false), “”)
source: excelvlookuphelp

(excel) sumproduct multiplying with another sheet

i have a little problem with final formulas in one of my column. How to start. maybe i will explain what i have a then what i want.
i have an excel worksheet with 3 sheets. i want to record goods and what are these goods made of. first is sheet called Goods where is possible to put number of goods i want to make. In this case i want to make 1x sandwich1 and at the same time 3x sandwich2. i dont want make sandwich3 this time.
Second sheet is Matrix sheet where I record every good and what it is made of. This sheet is basic sheet and all other sheets take list of goods (resp. ingredients) from this sheet. Simply when i want to make sandwich1 i look at matrix and know that i need 1x1pc of egg + 1x5g of cheese. And for 3x sandwiche2 i need 3x10g of sausages.
Final sheet is called Ingredients. It is a list of used ingredients from Matrix sheet (exactly same order) to make these sandwiches. I want to fill formulas into column B which would go through one ingredient ofter ingredient and count needed amount of it. So it would look into matrix in the same row and where there is some number it would multiply with number of items from Goods sheet. The list of goods is also in the same order as in the matrix sheet.
I hope you understand now what i want and will try to help me. I think there will be SUMPRODUCT, SUMIF and maybe INDERECT functions but i am not that skilled in excel
thanks for any suggestions
You can use MMULT function here - it's an "array formula" which you need to enter in a range. You can do that like this:
In Ingredients worksheet enter this formula in B2
=MMULT(Matrix!C2:E4+0;Goods!B2:B4+0)
[I'm assuming you have a European version of Excel where ; is used to separate arguments]
Now select the whole range B2:B4, press F2 key to select formula and hold down CTRL and SHIFT keys and press ENTER. This "array enters" the formula in the range and you should now see curly braces like { and } around the formula and also the correct results.
You cannot change part of that array now, only the whole thing
Note that I'm assuming that the contents of Goods!A2:A4 will be the same as Matrix!C1:E1 and in the same order. You can extend the ranges to be as large as you like as long as that principle still holds
I suspect that this is an issue of "when all you have is a hammer, every problem is a nail". For reasons known only to you you are using a spreadsheet to solve a problem that databases were made to do. Any solution to this problem in a spreadsheet will be entirely dependent on the integrity of your data - add another column or get things out of order and it will fail.
That said, what you have in your link is effectively a pivot table and what you need is the unpivoted version of this - the instructions for getting this are here.
When you have that, you can use the various database functions in excel to get your answer.

Resources