Excel SUMIF add Multiple Criteria - excel

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

Related

Summing a Dynamic Range based on multiple criteria

(Pictures included) -
I'm trying to write a formula that sums the Forecast Qty (dynamic range) based on multiple criteria. The criteria I want to base it on is the Part number and the month (Aug-21, Sep-21 etc). Each part can have multiple forecasts for each month, I've ran a match formula that shows the first row in which each part changes, but am not sure how to necessarily break it down further into months.
The previous pictures will give more insight into what I want. The first picture shows my raw data and the Match function I performed to find the first row of corresponding part. The second picture shows where I'd like the end result. The '100' in the selected cell is the result of the formula I have ran below.
=IF(VLOOKUP(F2,HIghJump!B:F,4,FALSE)>DATEVALUE("9/01/2021"),SUM(HIghJump!F2:F6))
My issue is how do I get the range in the sum formula (F2:F6), to change based on corresponding month. Beyond that, how do I get this formula to change based on different parts and different numbers of forecasts per month.
Any help is greatly appreciated!
Use SUMIFS:
=SUMIFS(HIghJump!$F:$F,HIghJump!$B:$B,$F2,HIghJump!$E:$E,">="&EOMONTH(K$1,-1)+1,HIghJump!$E:$E,"<"&EOMONTH(K$1,0)+1)
This should go in L2 and copy down. Change the K$1 to each corresponding target date when moving over columns.
If I am understanding correctly and if you have the newest version of Excel, then FILTER will come in handy.
Try:
=SUM(FILTER(HIghJump!F:F,
(HIghJump!B:B=$F2)*(HIghJump!B:B>=K$1)*(HIghJump!B:B<EOMONTH(K$1,0)+1))
Note that it is generally considered best practice to use partial ranges (e.g. $B$1:$F$100 and $B$1:$B$100 instead of B:F and B:B), so that might be something you would want to consider if performance is of importance to you. Also make sure your sheet name is really "HIghJump" instead of "High Jump" or some variation.
Answer:
Had to create a column using MONTH(x), then base SUMIFS off that vs the original month column.
=SUMIFS(HIghJump!F:F,HIghJump!H:H,MONTH(K$1),HIghJump!B:B,F2)

if cells have equal value in same column

I'm trying to create a formula for a countback feature in google sheets if possible.
I have a list of competitors race times (W4:W93) and have them ranked (X4:X93) and but if I get Identical times it throws out another formula for overall results.
my sticking point is I can't work out how to compare if the value in any cell is equal to another cell in the same column excluding itself, I have found plenty of info on equal values but not if they are in the same column.
any help would be much appreciated.
I note that this question has been voted down with no explanatory comments. The question is not on hold, it is not closed because it might be duplicate, or answered elsewhere, and no one has edited the question to provide greater clarity. That seems a pretty rough call to me.
In any event, I'm pretty sure that I've been in the situation described by the OP many times and I've had to be creative about finding and removing duplicate values. There are several ways to find/highlight/manipulate duplicate values, though Google doesn't seem to have as many options as Excel. One method is to use conditional formatting and this YouTube video explains it very well.
But I will use one of my all-time absolute favourite formulae to find duplicates. In addition, since the OP is working with 90 competitors, finding the duplicates is only the task, the OP also needs to arrange them in a way that assists analysis.
This Google spreadsheet shows the workings:
First, create a header, say, "Equal Rank" for column Y (the first column after "Ranking") and insert this formula in cell Y4:
=if(countif($W:$W,W4)=1,"Unique","Duplicate")
The formula has two components.
COUNTIF
IF statement
The COUNTIF looks at cell W4 (the race time) in the first row of results. The count range is Column W; the range could just as easily be limited to actual data but the key is that it is expressed as an "absolute" (note the $ signs in the range).The formula counts how many times the value in cell W4 appears in the range.
The IF statement evaluates the result of the COUNTIF. If the result appears only once, then the cell value is "Unique". If the value appears more than once, then it is a "Duplicate" value.
The OP has 90 competitors and will need to drill down to the duplicate results quickly. So, I suggest a variation of the classic formula, this:
=if(countif($W$4:$W$93,W4)=1,"",X4)
The formula still consists of two components, but if the result is unique, then no value is entered; conversely if the result is a duplicate, then the existing "Rank" (cell X4) is returned. BTW, this version shows how the range address would look if you evaluated only the populated range.
Now, sort the range A3:Y93 (I am assuming there is relevant data in columns A-V). FWIW, I inserted a column "Sequence" and gave it a numeric sequence so that once the "Equal Ranks" had been fixed, I could resort on the "Sequence" column to return the data to the original sort order - the OP may or may not need this.
To aggregate the duplicate values:
Select the Range> right-click > Sort range > "Data has Header Row" = checked> 'Sort by' "Equal Rank", Sort order: "A->Z".
From here, Race Times could be adjusted by a tenth, or hundredth, of a second to avoid duplicate times.
Once this is complete, select the full range again, and resort. In my case I used my "Sequence" column to return the data to the original sort order.

Excel VLOOKUP with multiple possible options in table array

I have two lists, the first is a set of users. The second list contains different encounter dates for these users.
I need to identify the date that is within 10 days of the "Renew Date" [Column C], but not before. With Member 1 this would be row 3 1/8/2017. With Member 2 this would be row 6, 1/21/2017.
Now using a VLOOKUP which the user before me who managed this spreadsheet obviously isn't viable as it's simply going to pickup the first date that has a matching Member ID. Is there a way to do this in Excel at all?
I have included a link to a sample file and a screenshoit of the sample data.
https://drive.google.com/file/d/0B5kjsJZFrUgFcUFTNFBzQzN4cm8/view?usp=sharing
To avoid the slowness and complexities of array formulas, you can try with SUMIFS but the problem is that if you have more than one match, it will add them, not return the first match. The sum will look like an aberration. Will work however if you are guaranateed that you have only one match in the data.
An alternative is also to use AVERAGEIFS, which, in case of multiple matches, will give you their average and it will look like a valid date and a good result. Enter this formula in D2 and fill down the column:
D2:
=AVERAGEIFS(G:G,F:F,A2,G:G,">="&C2,G:G,"<="&C2+10)
and don't forget to format column D as Date.
Try this
=SUMPRODUCT($G$2:$G$7,--($F$2:$F$7=A2),--($G$2:$G$7<=C2+10),--($G$2:$G$7>C2))
Format the result as date. See screenshot (my system uses DMY order)
Don't use whole column references with this formula. It will slow down the workbook.

excel count/sum stop count/sum match?

I have tried to see if this question has been asked before, but I can't seem to find an answer.
I have a column of cells (>3000 rows), with either a value of 1 or 0 (call this column A). The value will depend on the value in column B (which will contain either a value or nothing). The values in column B are a SUMIFS function based, summing from column C, and based on months in column D.
The values in B are paid out on the first business day of the next month. So, the SUMIFS function will calculate the dates that match the last month. This works well in theory, however, not every first business day is the first day of the month. This leads the SUMIFS function to not include everything in the correct month, and allows for some discrepancy, which, when you are dealing with people's money is not great. Further, this discrepancy is compounded across multiple periods (in some cases, there are over 100 periods, and a discrepancy of $1 in period 1 amounts to nearly $1000 in period 100)
What I am wondering is:
Is there any way that I can tell the SUMIFS function (column B) to stop when the value in column A is 0? This would tell the SUM function start the summing from the current value in column B and continue the function to the cell below the preceding value in column B.
I've seen suggestions that the MATCH function may work, but I can't see how to do this with either COUNT or SUM.
For security reasons, this solution needs to be entered into the cell, and can't be VBA. Also, it can't be too large, as it will need to be replicated across 200 worksheets in the workbook (not my file originally, and I would have done it differently, but that is another story). There is no problem entering another column or two if that is required.
Any help is gratefully appreciated.
EDIT:
Unfortunately, I can't post an image of the screenshot. I've included a similar screenshot (columns are not the same layout, but hopefully it gives the idea) here:
Rates calculations
The SUMIF formula is (for B2)
=SUMIFS(C2:C35,D2:D35,D2-1,A2:A35,1)
This works fine if I want all the values in the month, irrelevant of when the payment was made.
However, what I need the formula to do is:
SUM (C2:C35,D2:D35,D2-1, but stop when the first 0 is encountered in A2:A35)
Thanks
The INDEX function can provide a valid cell reference to stop using a MATCH function to find an exact match on 0.
This formula is a bit of a guess as there was no sample data to reference but I believe I have understood your parameters.
=SUMIFS(C2:index(C2:C35, match(0, A2:A35, 0)), D2:index(D2:D35, match(0, A2:A35, 0)), D2-1)
This seems to be something that will stand-alone and not be filled down so I have left the cell addresses relative as per your sample(s).

Find a cell (using VLookup) and use the cell location found in a range

I have simple data, with one column a daily incrementing date column, and the second column being a numeric value. I want to VLOOKUP the data for todays date (which I can do) and then get the average of this value plus the 7 days values before then as well.
Something a bit like:
=AVERAGE( VLOOKUP(today(),A2:B110,2,false)) : (VLOOKUP(today()-7,A2:B110,2,false))
But with the VLOOKUP returning the cell location rather than the data.
As with so many questions on here, I have searched, but I don't know the terms I am looking for and googling anything with VLOOKUP in the terms opens floodgates to questions that aren't quite what I'm asking. Many thanks!
Sounds like your dates are in strictly increasing order, correct? In which case, assuming you're using Excel 2007 or later, you could use:
=AVERAGEIFS(B2:B110,A2:A110,"<="&TODAY(),A2:A110,">="&TODAY()-7)
This INDEX formula will also work, though is not as efficient:
=AVERAGE(INDEX(B2:B110,MATCH(TODAY(),A2:A110,0)):INDEX(B2:B110,MATCH(TODAY(),A2:A110,0)-7))
Regards

Resources