I have a worksheet that is 200 columns wide. I am using VLookup to return values based off of a date in the first column.
Due to the width of the spreadsheet, troubleshooting (or even determining the column number to use) is a real pain. I tried naming the column, and replacing the column 45 with the name, but I get a Value error.
There are two tabs: recap and Roll-up. In the recap tab, I have:
=VLOOKUP(MONTH($C$4),Rollup,45)
C4 is the date that users want to look up in the named range Rollup first column.
The Rollup range is defined as:
='Roll-up'!$A$2:$FF$15
The formula needs to be something non-power Excel users can understand and use for future growth of their workbooks (not that I don't like doing all their work for them).
Well, I guess you could use something like this:
=VLOOKUP(MONTH($C$4),Rollup,MATCH("(EAF) Equivalent availability factor", INDEX(Rollup,1,0),0),0)
MATCH("(EAF) Equivalent availability factor", INDEX(Rollup,1,0),0) gets the column number in Rollup in which there is (EAF) Equivalent availability factor.
It's not so simple, and if you want, you should also be able to use a simpler:
=VLOOKUP(MONTH($C$4),Rollup,MATCH("(EAF) Equivalent availability factor", 'Roll-up'!$A$2:$FF$2,0),0)
To reduce the number of functions, at most. From experience, non-Excel users usually have difficulty with even understanding how VLOOKUP works, so I guess if they don't understand it at all, it might be better having something that could be more robust to changes such as row insertions.
INDEX(Rollup,1,0) by the way gives the first row in the range Rollup.
Related
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.
The situation: I have an automatic procedure for gathering data from different input-sheets and presenting in a pivot-friendly format. It appears others are in need of the same data, though they want it formatted slightly differently (and they are not friends with excel). I therefor have a version of my table formatted as they want it (with empty columns where my extract does not contain any data).
The table (both) is one line for each department for each year for each cost/income (from now, cost) category. The raw data contains the cost for each year, though some of the users want it to be cost delta from initial year. I want:
One column for raw cost (X). One column for delta cost (Y). One output column (Z) that contains one of those two values, depending on dropdown selection. The first two columns are situated to the right of the "select with mouse and copy these"-columns, so that I dont need to teach the other users how to select non-adjecent columns :P (just letting u know the level of understanding i have to work with here)
Now the naive approach to this would be to have an if-statement in column Z like this:
=IF(selected_Calc="Use raw cost";[#[X]];[#[Y]])
Alternatively nest more ifs (one for "Use difference to 2019", and potentially add more nesting if more ways to show the value should appear in future)
This works. However, it isnt as elegant as I would like it, and if I indeed end up with more ways to calculate this for other people, it will be a lot of nested ifs.
I was therefore considering something like this:
=INDIRECT("[#["INDEX(mapTab_out;match(selected_Calc;mapTab_in;0))&]]")
But this gives a #ref, and tbh i didn't really expect it to work.
The idea is though: .
Have a range mapTab_in. This has the different selections for the dropdown box.
Have the adjecent range mapTab_out. This has the name of the column (X,Y...) that contains the desired calculation)
Have in column Z a formula for selecting which column's (X,Y...) value is to be displayed in Z
The google-stuff I have found so far all seem interested in using the indirect function from outside the table, and usually want to sum an entire column. I have used this in the past. The "ThisRow" things like using # dont seem to work with indirect though. Any ideas, or have I simply made some beginner-error in my formula?
Assuming it's in the same table, you can take advantage of implicit intersection and simply use:
=INDEX(Tablename,,MATCH(selected_Calc,Tablename[#Headers],0))
where selected_Calc is the name of the column you want back. (You could make that the result of a further INDEX/MATCH if you want to use a lookup table for some reason.)
Using COUNTIF and VLOOKUP, the goal is to count my inventory of Laptops and return the number I have in stock.
My current formula is this:
=COUNTIF($A$3:$A$10000,H4)
As my table only has one entry for "Laptop", the formula evaluates to 1.
The next step was to incorporate some sort of VLOOKUP for quantity. As an example, Row 17 has an entry for "Monitor" with a specific model, with a column E (quantity) value of 5:
Monitor HP Compaq LA1951G 1FL SVR 5
I could use a VLOOKUP here:
=VLOOKUP(H6,$A$3:$E$10000,5,FALSE)
However, I have a second set of monitors with a different model. From what I understand of VLOOKUP, the formula stops evaluating at the first match.
I'm considering simply listing every possible model in our environment and strictly using VLOOKUP only, but this makes my life more complicated.
Any suggestions on a better way of doing this before I do a lot of manual work would be appreciated. I've linked a sanitized copy of my workbook via Google Sheets here.
I believe the SUMIF() function would be more useful here.
Replace the
=COUNTIF($A$3:$A$10000,H4)
with
=SUMIF(A:E,H4,E:E)
Having done this same process for many companies, I suggest you also consider a Pivot Table. It can automatically update, auto-sum everything, and auto-count everything if you've set it up properly.
Pivot Tables also work in Excel and Sheets equally well. Just make sure that you're defining entire Columns of data for the basis of the data sets and it will be dynamic! E.G. Don't do A1:F50, do A:F for your data set definitions.
I have a pricelist, with currently 5 different categories of products. Each product will have to have two different prices. Depedning of the product and the type of price, the calculation will be different. Therefor I've used INDEX/MATCH to find the formula needed, from a table I created.
Below a screendump, and I wanted to attach the Excel fil, but canøt seem to work out how.
Question: HOW do I then "run" the formula I fetched? -I've tried different suggestions on using EVALUATION, but it doesn't seem to cut it? Also I've tried "Indirect' on the whole formula, without success.
I would like to avoid any VBA for this case.
Can anybody provide some insight?
You could but if I understand properly, the only thing changing in the formulas is the "muliplier" number, then it's better to lookup that number instead of the whole formula. The other method (which would use Evaluate etc) is not be considered "good practice" for a number of reasons.
EDIT:
I didn't see the 2nd varying value (since I was on the SO mobile app) but it's still not an issue since it would a target column. You could be thinking of the opposite: sometimes lookups based on multiple criteria can get complicated, but this a matter of more data, as opposed to adding criteria for the lookup.
VLookup would have been the simplest method, like G2 could have been:
=VLOOKUP(E2, $J$4:$L$8, 2, False)
...to return the second column of range J4:L8 where the first column equals E2. (Then for the next required column, same formula except with 3 instead of 2.)
Since I wasn't sure more columns could be added one day, I allowed for that by, instead of specifying "Column 2 or 3" etc, it finds the column dynamically by name. (So the multiplier/factor used in G2 will change if you change the title in G1 to the name of a different column existing in the target data chart.
For the sake of neatness as well as potential of additional columns like G & H, I moved the lookup table to a separate sheet. It can stay out of the way since you won't need to see or change it very often. (If the same chart was going to be referenced by many workbooks, you could even move it to a separate workbook and point all formulas at that, since it's always best to have one copy of identical data instead of many in different workbooks.
Also to assist with potential future changes (and just to be tidier), instead of referring to the target table range addresses (like "J4:L8" etc) I named two ranges:
the table of multiplier/factor data can be referred to by it's address, or by myMultipliers
the titles of the same table is also called myMultiplierTitles (used to match to the titles of column G & H on the original sheet.
Formula
After those changes, the lookup formula in G2 is:
=INDIRECT(VLOOKUP($E2,myMultipliers,MATCH(G$1,myMultiplierTitles,0),FALSE)&ROW())*VLOOKUP($E2,myMultipliers,MATCH(G$1,myMultiplierTitles,0)+1,FALSE)
INDIRECT returns the value of a cell that you refer to by name (text/string) as opposed to directly (as a range). For example:
=INDIRECT("A1")
returns the same as
=A1
...but with INDIRECT we can get the name from elsewhere (a cell, function or formula). So if x="A1" then =INDIRECT(x) returns the same as the 2 above examples.
Your original plan of storing the entire formula in a table as text would have worked with the help of INDIRECT and/or EVALUATE but I think this way is considered better practice partly because it facilitates easier future expansion.
The formula is longer than it would have been, but that's mostly because it's dynamically reading the field names. And size doesn't matter. :-)
I am using this formula for SUMIF which is working fine, but I need to add another criteria which is the DATE. I only want the jobs to sum total if the date is the same in column A. How do I accomplish this? When I use SUMIFS I get an error "too few arguments".
=SUMIF($B$2:$B$786,I2,$F$2:$F$786)
Setting the Stage
When making my initial response, I didn't notice that the OP's sample data included two separate data ranges. There is the main "table" with columns including DATETIME, PRODUCT and AVG CYCLE MINUTES. These are the data to be summed across. However, the sums are not to appear against these rows, but against the rows in the second "table" which has the column REFERENCE LIST. REFERENCE LIST matches with the PRODUCT column in the first table and so provides one of the criteria for the SUMIF(S). The second criteria was to be DATE. However, since the second table doesn't include a date column it isn't obvious where this should come from.
In discussion with the OP, we realised that we wanted a the total (or, as it turned out, average) of "AVG CYCLE MINUTES" for each combination of DATETIME and PRODUCT. I walked the OP through the process of creating a PivotTable to do this.
Options
If we want to achieve the same or similar by means of SUMIF or SUMIFS, we need to make a decision about the DATE criteria. Either (a) the second table needs to include dates as well as PRODUCTs, or (b) we need to find a way to pick the date we're interested in.
Sum for Every Combination of DATE and PRODUCT
For option (a), an answer similar to my original one would work:
=SUMIFS(F:F,B:B,I2,A:A,J2)
where column J is the new column of dates. The full list of date/product combinations could have been swiftly produced by copying the relevant columns of the main data to elsewhere and using Excel's "remove duplicates" functionality.
Sum for single DATE per PRODUCT
For option (b), if you wanted to sum up all the data relating to "today", that could be done using:
=SUMIFS(F:F, B:B, I2, A:A, today())
(with credit to #JNevill).
What else might we want? Perhaps the most recent date the PRODUCT appears against? Or the earliest? If you have EXCEL 2016 (or better) ...
=SUMIFS(F:F, B:B, I2, A:A, MAXIFS(A:A,B:B,I2))
This would give the total minutes for the relevant PRODUCT on the latest date recorded for that PRODUCT. For the earliest date replace MAXIFS with MINIFS.
Alternatively, if the data is sorted so that the date you want will be the first to appear against any given PRODUCT you can use:
=SUMIFS(F:F, B:B, I2, A:A, INDEX(A:A,MATCH(I2,I:I,0)))
Miscellanea
I'd normally use VLOOKUP rather than INDEX/MATCH (a habit I've yet to acquire), but in the current data structure the columns are in the wrong order for that.
Since further discussion revealed that the OP actually wanted averages not totals, it's worth noting the existence of AVERAGEIFS.
NOTE: in my original answer (below), I reference the exact ranges rather than entire columns. There may be some marginal performance loss doing things as above, but I've never noticed. Though you need to be sure there are no extra data beneath the stuff you're interested in. On the other hand, there are definite benefits, it's easier to enter the formula and it will not need amending for larger (or smaller) data sets. (Thanks for reminding me of this #Jeeped)
NOTE 2: Since there is there is nothing you can do with SUMIF that can't also be done with SUMIFS, there is no harm in using the latter even when the former would suffice. That way you only have one function to remember and it's the most useful one. (Another good idea from #Jeeped)
Original Answer
As others have said, I think you want SUMIFS. Here the sum_range comes to the front, and you follow that with pairs of "criteria range"s and "criteria" like this:
=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)
In your case, I think that means you want:
=SUMIFS($F$2:$F$786,$B$2:$B$786,I2,$A$2:$A$786,A2)
When I wrote this, the relevant Microsoft Support page was here