How to use COUNTIF in Excel that is dependent on two conditionals? - excel

The first formula below is the one that operates correctly – its function is to tally up all “x’s” in a particular column when another column in that row says “Spain” and another column in that row says “Issued”.
=COUNTIFS(L$3:L$89,"=x",$A$3:$A$89,"=Spain",$H$3:$H$89,"=Issued")
The problem is with this next formula where I want it to do the same as above, plus add to it the tally for other rows that have “France”, for example. I know this formula isn’t structured correctly because the output is “zero”, when it should be “2”.
There are more countries that I want to add to this command eventually, but if I could get it to operate correctly with just two countries, adding the others should be easy. I’m not sure if the formula is the problem, or if I’m using the wrong function command, or what.
=COUNTIFS(K$3:K$89,"=x",$A$3:$A$89,"=Spain",$H$3:$H$89,"=Issued",K$3:K$89,"=x",$A$3:$A$89,"=France",$H$3:$H$89,"=Issued")
 

Something like this:
Entered using Ctrl+Shift+Enter

Related

VLOOKUP Multiple Columns If Not Found In First Column

I have a long list of part numbers where I need to be able to lookup and retrieve information on them.
These parts can have several alternative part numbers. I have figured out how to get the data returned if my data table only shows one of the possibly part numbers.
The issue is that I want it to be able to look up the columns to find a matching value.
As in the picture below for example. 5-E26 is the equivalent to E5-25. So if I input 5-E26 in the cell, I want it to continue searching to find the value in B7, and return the data as done A4 and A5.
Is this possible to do with Vlookup? Or is there a smarter method for it?
I struggle to fully understand how your data works but here is a possibility:
So the translated version of the formula I used in G2:
=INDEX($D$1:$D$5,AGGREGATE(15,3,((($A$2:$D$5=F2)/($A$2:$D$5=F2))*ROW($A$2:$A$5)),1))
You could also try (in my case):
=INDEX($D$1:$D$5,SUMPRODUCT(($A$2:$D$5=F2)*ROW($A$2:$D$5)))

Excel Formula with OFFSET Fails When Copied to Different Sheet

I've been struggling with this longer than I care to admit, but I have a fairly simple OFFSET function call which works on one sheet, but if I copy it to a different sheet it gives a #VALUE error.
On a sheet named "Deliverable" I have this formula in a cell:
=OFFSET(Deliverable!$B$72,1,0,,3)
and it works fine.
If I go to any other sheet and use the same exact formula, or use it in the Name Manager, it gives a #VALUE error.
If I leave off the final parameter indicated the number of columns I want, it does work:
=OFFSET(Deliverable!$B$72,1,0)
but of course isn't giving me the range I need.
Any idea what's going on with this?
I'm using Excel 2016 on Windows 7.
-- Updated Info --
In a nutshell, my spreadsheet has two cells which I'm using as dropdown lists, where the 2nd cell's list feeds off the selection in the first. The data they are based on has this format:
OptionA A B C D
OptionB A B
OptionC D E F
So the first dropdown uses a simple Data Validation source pointing to the column with OptionA, OptionB, etc. Once that's chosen, the second dropdown list should contain the appropriate options for the one selected. So if OptionB is selected, then the 2nd dropdown list should show A and B.
When I initially wrote this, the data validation source was just a simple VLOOKUP entry, but the lists often had blanks since the number of options varies for each entry. Wanting to fix it up a bit, I ended up with this formula:
=OFFSET(Deliverable!B72,Deliverable!B87,0,1,COUNTA(OFFSET(Deliverable!B72,Deliverable!B87,0,1,5)))
There won't be any more than 5 options, and there are no empty cells in the middle of the data to filter out.
In one spreadsheet I have I used this as a named range definition, then specified the named range for the cells data validation source and it worked. In this other spreadsheet however, it gave me the error described earlier.
However, it looks like when I enter the statement directly into the data validation source field and not in the name manager, it works as expected.
Am I taking the totally wrong approach?
What is it that you want this formula to do? As written, it is returning a block of three horizontal cells. The #VALUE error is Excel's way of telling you "Hey, you're trying to return three cells, but I can't fit them all in the one cell that you are calling this formula from".
The reason you see a result in some places and not others is because of something called Implicit Intersection. Give it a spin on Google. But basically, it just returns whichever one of those three results corresponds to the column that the formula is entered into. If you copy that exact same formula to say row F you will see that it returns a #VALUE error there, because it doesn't know what cell it should return given the column you're calling it from doesn't match any of the cells it is returning. The fact that you don't know this indicates that the formula you're using doesn't in fact do what you think it does.
--UPDATE --
Okay, following your further clarificaiton it seems that you're talking about Cascading Dropdowns aka Dynamic Dropdowns. Lots of info on Google about how to set these up, but you may be interested in an approach I blogged about sometime back that not only provides this functionality, but also ensures that someone can't later on go and change the 'upstream' dropdown without first clearing the 'downstream' one should they want to make a change.
Note that those links talk about a slightly complicated method compared to others, but the method has it's advantages in that it also handles more levels than two, and your DV lists are easily maintained as they live in an Excel Table.
This sounds like an array equation. Try hitting Ctrl+Shift+Enter in the other sheets to validate it as an array equation.
Whenever you need to reference ranges instead of single cells, Excel needs to know that you are working with arrays.

How to do this lookup operation in Excel

There are two sheets (sheet1 & sheet2) in my Excel file, it's like daily work routine (entry date, pickup date, dispatch date). Some details will change as per the work flow and even new entries will appear.
I just need to compare both files if a change occurred in one cell it must have to show entire row of sheet1 (I can't specify exact headline for that all details are too precious and it has more than 100 headlines).
So if there is any formula for that please let me know like
IF+VLOOKUP
please correct below given formula
=If(RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX)=(RECHERCHEV(A2,sheet2!A8:FM257,1,FAUX);"";RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX))
It's the French version.
Try this array formula in cell A1 of sheet3 and drag across and down.
=IF(AND(EXACT(Sheet1!1:1,Sheet2!1:1)),"",Sheet1!A1)
Not really sure what you're looking to do here, and I don't speak french, but it looks like you have an extra parenthesis before your 2nd RECHERCHEV function.
Try this :
=If(RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX)=RECHERCHEV(A2,sheet2!A8:FM257,1,FAUX);"";RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX))
Though I'm not sure why the IF function uses semi-colons, but the RECHERCHEV uses commas, so maybe this:
=If(RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX)=RECHERCHEV(A2,sheet2!A8:FM257,1,FAUX),"",RECHERCHEV(A2,sheet1!A8:FM264,1,FAUX))
Also it seems you want the entire row to update, so I am not sure how this vlookup would work since the arrays start in different rows than the lookup value.

Excel Function Return Max Two Values

I am looking to get some help with a function that I am sure is an option but I sadly have no clue on how to implement.
Basically, I'd like a formula to go from C21:C50 and look for the top two values. Based upon which two are the top, it would reference the name in B column and populate that value in the another cell (the cell the formula resides in)
If you look at the image, in the primary field, we'd have Steve. Secondary would be Alan.
Is this something anyone can help with? I simply am lost :(
Try
=INDEX($B$3:$B$7,MATCH(LARGE($C$3:$C$7,ROW(A1)),$C$3:$C$7,0))
with Bob in cell B3 and the "primary" formula in cell C9. Copy down to cell C10.
If dealing with integers, you can simply add +1/ROW([range]) to avoid doubles:
=INDEX($B$3:$B$7,MATCH(LARGE($C$3:$C$7+1/ROW($C$3:$C$7),ROW(A1)),$C$3:$C$7+1/ROW($C$3:$C$7),0))
This is an array-formula and must be confirmed with ctrl+shift+enter!
However, this may fail for numbers like 5.01 or 4.99. For that case just use it in combination with RANK.EQ:
=INDEX($B$3:$B$7,MATCH(LARGE(RANK.EQ($C$3:$C$7,$C$3:$C$7,1)+1/ROW($C$3:$C$7),ROW(A1)),RANK.EQ($C$3:$C$7,$C$3:$C$7,1)+1/ROW($C$3:$C$7),0))
This is an array-formula and must be confirmed with ctrl+shift+enter!
The steps as picture:
The first table shows the direct adding of 1/ROW which is used for LARGE and MATCH to get the row if doubles exist (so INDEX can pick the correct one)
The second table shows how the values get replaced by their rank with RANK.EQ and then are treated the same like the first table.
The third (grey) table shows, what would happen if the first formula is applied to the second table (to demonstrate how the ranks get messed up).
For Excel 2007 just replace the RANK.EQ($C$3:$C$7,$C$3:$C$7,1) with RANK($C$3:$C$7,$C$3:$C$7,1).
If you still have any questions, just ask :)

Using SUMIFS with multiple AND OR conditions

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.

Resources