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.
Related
I am trying to summarise data I have in a table into months Jan,Feb,Mar etc, and need to separate the counts of various strings (such as HE(Technical)).
Some context: column "B" of my Data sheet are dates (not necessarily in chronological order), column "O" are keywords/strings.
I want to sort all instances of a particular string by the month based on the dates inputted in column "B".
May I know how I would go about this?
My current formula (in title) only returns zeroes.
Instead of working with an =IF(...,CountIf()) construction, you might try to work with a =CountIfS() formula (the IfS gives the opportunity to combine criteria.
For example, I have tried the following formula and the result was quite promising:
=COUNTIFS(B1:B3,2,O1:O3,"*HE*")
Good luck
I have array of numbers in a single column like this:
I want only that numbers for which corresponding negative numbers exist. If number exist 2 times, but negative number exist only one time, then I wanted to retain one positive and one negative number. Similarly, if number exists 3 times, and negative number appears only two times, then I want 2 set of numbers including positive and negative. In this case, I wanted to get output:
5 2 -2 -5
Orders of numbers are not relevant for me. Please do not use VBA. You can create multiple column and apply filter at the end.
Thank you for the response, but I wanted to get the data in column next to the values. Like:
5
2
-2
-5
Please help.
Here's another Office 365 solution:
Name the data range DATA
Put this formula anywhere: =CONCAT(REPT(-ROW(A1:A100)&" "&ROW(A1:A100)&" ",COUNTIF(DATA,"="&ROW(A1:A100)*IF(COUNTIF(DATA,"="&-ROW(A1:A100))<COUNTIF(DATA,"="&ROW(A1:A100)),-1,1))))
That will output the pairs into one cell.
Here's a slightly modified Step 2, which excludes duplicates: =CONCAT(IF((COUNTIF(DATA,"="&-ROW(A1:A100))>0)*(COUNTIF(DATA,"="&ROW(A1:A100))>0),-ROW(A1:A100)&" "&ROW(A1:A100)&" ",""))
Looks like this:
The data doesn't need to be sorted. Both methods work up to 100, but you can easily expand that by changing A100 to A1000 or whatever you need.
Use the vlookup formula to identify the rows, and you can use the Filter & Unique formula to get the list, or a pivot table.
First, immediately next to your data use the formula:
=vlookup(A1*-1,$A$1:$A$1,1,0)
For non-365:
This will produce an error for each instance that doesn't have a match. You can filter at this point to get your list from the existing table. You can also create a pivot table under the Data tab of your ribbon and inserting a pivot table. Filter the #N/A from there to get an exclusive list without hidden rows.
For 365:
You can use the following combination of formulas to get the exclusive list as well.
=UNIQUE(FILTER(B1:B8,ISNUMBER(B1:B8)),0,0) or =UNIQUE(FILTER($B$1:$B$8,ISNUMBER($B$1:$B$8)),0,0) should yield the same results
As ScottCraner mentioned, you can circumvent the helper column in 365 by modifying the formula a bit more:
=UNIQUE(FILTER(A1:A8,ISNUMBER(MATCH(-A1:A8,A1:A8,0)),"")
The Match here is doing something similar to the Vlookup, but housing that logic within the formula, so it's a cleaner solution in my opinion.
Using your data the result was { -5,-2,2,5 }
These are spill formulas so you only need to put it in one spot and it will expand the formula over the adjacent cells below where it's entered for however many cells needed to list all the unique numbers that occur. It takes into account the negatives and so on. This may be a 365 formula, so if you're on another version of excel it may not work.
Edit: Adjusted the instructions to fully address the question.
I have the following Table as an example:
Name Task Amount
Jennifer Sing 10
Tom Dance 15
Joe Jump 72
Mandy Scream 10
And supporting lists:
Names Tasks
Jennifer Dance
Joe Sing
Jump
I need to find the total of the sum of amounts where Name is in the Names list AND Task is in the Tasks list. In other words, if the person AND the task are in the list of relevant people and tasks, total their amount.
So, for example, the total would be 10+72=82.
I have tried to name the ranges of the criteria lists as RelevantNamesList and RelevantTasksLists, and the input table columns as Names and Tasks and Hours, and then using sumif, however I am not even able to get it to work with a single condition.
=SUMIF( Names, ( -- ( ISTEXT(VLOOKUP( Names, RelevantNamesList, 1, FALSE))) ), Amounts)
The actual result I get using the above code is a 0, which is obviously not correct. I have also tried to use sumproduct, with no success. I am beginning to think that I wont be able to use this without helper columns.
Is there a way to do this without helper columns?
Thanks in advance!
Jacqueline
Give this a try:
=SUMPRODUCT((COUNTIF(<Names To Lookup>,<All Names List>)>0)*(COUNTIF(<Tasks To Lookup>,<All Tasks List>)>0)*<All Amounts List>)
So if you had a data setup like this:
Then the formula would be:
=SUMPRODUCT((COUNTIF($E$2:$E$3,$A$2:$A$5)>0)*(COUNTIF($F$2:$F$4,$B$2:$B$5)>0)*$C$2:$C$5)
EDIT:
Per comment, the lookup criteria could be partial matches. For example, the name in the list is Ms Jennifer Keim and what's being looked up would be Jennifer. In order to accomodate this, you'd need to switch tactics to the DSUM function. This means that you'll need to alter how you setup the criteria.
There are two ways to do this, the first is to create a row for each set of criteria you want, and the second is to have the limited list like you originally have and then setup criteria formulas you then feed into the DSUM. Here's the data setup for the first scenario (note that the lookup headers must exactly match the table headers and that you're putting the wildcards for partial match directly in the criteria):
The DSUM formula in this scenario is:
=DSUM($A$1:$C$5,"Amount",$E$1:$F$7)
For the second scenario, we setup the limited criteria like you originally had it, but now we need helper formulas to feed into the DSUM. Note that the helper formula headers must not be in your original datatable (here i've added "Check" to the end of the header names as an example):
The formulas need to reference the first cell in your datatable and perform the check against your criteria. The DSUM formula will expand that formula's check against every row, so we only need this for the first row to establish the logic that DSUM will use. Here are the two formulas for NameCheck (cell H2 in this example) and TaskCheck (I2). We are using these formulas to allow for partial matches when looking up the criteria against the datatable:
NameCheck: =SUMPRODUCT(--(LEN(SUBSTITUTE(A2,$E$2:$E$3,""))<LEN(A2)))
TaskCheck: =SUMPRODUCT(--(LEN(SUBSTITUTE(B2,$F$2:$F$4,""))<LEN(B2)))
Now the DSUM criteria argument references those formula cells and becomes:
=DSUM($A$1:$C$5,"Amount",$H$1:$I$2)
For further reading and information regarding the DSUM formula, Contextures has a great explanatory article with an example workbook you can download and experiment with: https://contexturesblog.com/archives/2012/11/15/dsum-and-excel-tables-sum-with-multiple-criteria/
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
I would like to create a succinct Excel formula that SUMS a column based on a set of AND conditions, plus a set of OR conditions.
My Excel table contains the following data and I used defined names for the columns.
Quote_Value (Worksheet!$A:$A) holds an accounting value.
Days_To_Close (Worksheet!$B:$B) contains a formula that results in a number.
Salesman (Worksheet!$C:$C) contains text and is a name.
Quote_Month (Worksheet!$D:$D) contains a formula (=TEXT(Worksheet!$E:$E,"mmm-yy"))to convert a date/time number from another column into a text based month reference.
I want to SUM Quote_Value if Salesman equals JBloggs and Days_To_Close is equal to or less than 90 and Quote_Month is equal to one of the following (Oct-13, Nov-13, or Dec-13).
At the moment, I've got this to work but it includes a lot of repetition, which I don't think I need.
=SUM(SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Oct-13")+SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Nov-13")+SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Dec-13"))
What I'd like to do is something more like the following but I can't work out the correct syntax:
=SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,OR(Quote_Month="Oct-13",Quote_Month="Nov-13",Quote_Month="Dec-13"))
That formula doesn't error, it just returns a 0 value. Yet if I manually examine the data, that's not correct. I even tried using TRIM(Quote_Month) to make sure that spaces hadn't crept into the data but the fact that my extended SUM formula works indicates that the data is OK and that it's a syntax issue. Can anybody steer me in the right direction?
You can use SUMIFS like this
=SUM(SUMIFS(Quote_Value,Salesman,"JBloggs",Days_To_Close,"<=90",Quote_Month,{"Oct-13","Nov-13","Dec-13"}))
The SUMIFS function will return an "array" of 3 values (one total each for "Oct-13", "Nov-13" and "Dec-13"), so you need SUM to sum that array and give you the final result.
Be careful with this syntax, you can only have at most two criteria within the formula with "OR" conditions...and if there are two then in one you must separate the criteria with commas, in the other with semi-colons.
If you need more you might use SUMPRODUCT with MATCH, e.g. in your case
=SUMPRODUCT(Quote_Value,(Salesman="JBloggs")*(Days_To_Close<=90)*ISNUMBER(MATCH(Quote_Month,{"Oct-13","Nov-13","Dec-13"},0)))
In that version you can add any number of "OR" criteria using ISNUMBER/MATCH
You can use DSUM, which will be more flexible. Like if you want to change the name of Salesman or the Quote Month, you need not change the formula, but only some criteria cells. Please see the link below for details...Even the criteria can be formula to copied from other sheets
http://office.microsoft.com/en-us/excel-help/dsum-function-HP010342460.aspx?CTT=1
You might consider referencing the actual date/time in the source column for Quote_Month, then you could transform your OR into a couple of ANDs, something like (assuing the date's in something I've chosen to call Quote_Date)
=SUMIFS(Quote_Value,"<=90",Quote_Date,">="&DATE(2013,11,1),Quote_Date,"<="&DATE(2013,12,31),Salesman,"=JBloggs",Days_To_Close)
(I moved the interesting conditions to the front).
This approach works here because that "OR" condition is actually specifying a date range - it might not work in other cases.
Quote_Month (Worksheet!$D:$D) contains a formula (=TEXT(Worksheet!$E:$E,"mmm-yy"))to convert a date/time number from another column into a text based month reference.
You can use OR by adding + in Sumproduct. See this
=SUMPRODUCT((Quote_Value)*(Salesman="JBloggs")*(Days_To_Close<=90)*((Quote_Month="Cond1")+(Quote_Month="Cond2")+(Quote_Month="Cond3")))
ScreenShot
Speed
SUMPRODUCT is faster than SUM arrays, i.e. having {} arrays in the SUM function. SUMIFS is 30% faster than SUMPRODUCT.
{SUM(SUMIFS({}))} vs SUMPRODUCT(SUMIFS({})) both works fine, but SUMPRODUCT feels a bit easier to write without the CTRL-SHIFT-ENTER to create the {}.
Preference
I personally prefer writing SUMPRODUCT(--(ISNUMBER(MATCH(...)))) over SUMPRODUCT(SUMIFS({})) for multiple criteria.
However, if you have a drop-down menu where you want to select specific characteristics or all, SUMPRODUCT(SUMIFS()), is the only way to go. (as for selecting "all", the value should enter in "<>" + "Whatever word you want as long as it's not part of the specific characteristics".
In order to get the formula to work place the cursor inside the formula and press ctr+shift+enter and then it will work!
With the following, it is easy to link the Cell address...
=SUM(SUMIFS(FAGLL03!$I$4:$I$1048576,FAGLL03!$A$4:$A$1048576,">="&INDIRECT("A"&ROW()),FAGLL03!$A$4:$A$1048576,"<="&INDIRECT("B"&ROW()),FAGLL03!$Q$4:$Q$1048576,E$2))
Can use address / substitute / Column functions as required to use Cell addresses in full DYNAMIC.