Excel - Find the correct value out of multiple - excel-formula

I'm currently trying to extract a set of values corresponding to some other but can't succeed.
On my sheet, I have 2 columns (Country (C) / online(D))
Wrong
There are multiple values.
In columns F and G, I display the results.
I'm using a formula with INDEX/MATCH to do this but the problem it only takes into account the first value found (so for country BEL, first value is "yes", it will show "yes" in column G). My formula is
=INDEX(D2:D8,MATCH(F2:F4,C2:C8,0))
What I'd like is if for BEL there are "yes" and "no" values, the result will show me "no". so "yes" is a default value and if there are "yes" and "no", since there is a different value for BEL, it will show this other value and give this
Right
any idea how to do this ?
Hope it's clear.
Thanks a lot for your help.

You can use COUNTIFS to get the number of matches where ONLINE = "no" for each country, then use that as an input to an IF statement that will output "no" if the count of "no" in the table is > 0
here is a formula to get started:
=IF(COUNTIFS(B:B,"=no",A:A,E4)>0,"no","yes")
COL A has the Countries, B the Online state, and E is the summary section

Related

excel formula to give the priority to a value from a range of values in a column

This is probably a simple fix (although me thinking this, means it probably isn't), so I apologize in advance if this is mere child's play.
In an excel sheet I am working on, I have a range (for the sake of this example is B1:B10) which can contain one of 5 variables (not including blanks) - OG, D, L, PP or C.
I require a formula in another cell to review the range in question and output a value based on the following rules in this priority:
If OG appears anywhere in the column, regardless of other inputs, display OG;
If D and L and/or PP and/or C appear in the column, display OG;
If only D appears in the column, display D;
If only PP appears in the column, display PP;
If only L appears in the column, display L;
If only C appears in the column, display C; and
If all cells within the column are blank, display blank
For rules 1-6, any blank cells within the column should not be considered. It is only where all cells are blank, i.e. rule 7, that this should be considered.
I have tried IF formulas but have found these only consider a single cell.
I've tried searching everywhere and can't find anything on this (although this is probably down to me not phrasing my question/searches correctly).
Any help would be much appreciated. Thanks in advance!
Use an 'if' formula, but for your condition, Use 'MATCH': for eg, for checking the first case:
=IF(MATCH("OG",$B$1:$B$10,0), "OG", "FALSE")
The above formula will put "OG" if it's in any of the cells, else "FALSE".
In a similar way, change all your logic, but set the conditions to use match to see if they exist somewhere in the column
Here is a possible solution. For your 6 first tests, you type each of these formulas in a cell (I did it from D1 to D6) :
Test 1 (D1)
=IF(COUNTIF(B1:B10;"OG");"OG";"")
Test 2 (D2)
=IF(AND(COUNTIF(B1:B10;"D");OR(COUNTIF(B1:B10;"L");COUNTIF(B1:B10;"C");COUNTIF(B1:B10;"C";"")));"OG";"")
Test 3 (D3)
=IF(COUNTIF(B1:B10;"D")=DCOUNTA(B1:B10);"D";"")
Do the same for test 4 to 6 by replacing "D" by "P","L","C".
Now your target cell :
=IF(D7="empty";"";INDEX(D1:D7;MATCH(TRUE;INDEX((D1:D7<>"");0);0)))
This last cell will simply show the first non empty value of your test cells.
The last test is kind of implicit.
I hope I got your tests right, let me know if not.
EDIT : Sorry for the numerous editings, my Office isn't in English, that's a pain to translate the formulas. They should be working now.
EDIT 2 : Your last test is not implicit and there is a possibility that last cell show "NA". So you should add this to D7 :
=IF(COUNT(B1:B10)=0;"empty";"*A value to show if all tests didn't pass*")
Also now your target cell has D7 in its formula's range.
I feel condition 2 little confusing, Do you mean D is mandatory and other (L,PP,C) are option to result "OG" ?
What should be the result if we have multiple input of (L,PP,C) in the range ? Should it be BLANK?
I came up with this formula if D is mandatory in condition 2 and formula will return Blank if only other 3 inputs are there except "OG" and "D"
Formula: =IF(COUNTIF(B1:B10,"OG")>0,"OG",IF(AND(COUNTIF(B1:B10,"D")>0,SUM(COUNTIF(B1:B10,"D"),COUNTIF(B1:B10,"L"),COUNTIF(B1:B10,"PP"),COUNTIF(B1:B10,"C"))>1),"OG",IF(COUNTIF(B1:B10,"D")=COUNTA(B1:B10),"D",IF(COUNTIF(B1:B10,"L")=COUNTA(B1:B10),"L",IF(COUNTIF(B1:B10,"PP")=COUNTA(B1:B10),"PP",IF(COUNTIF(B1:B10,"C")=COUNTA(B1:B10),"C",""))))))
First Condition:
Condition 2:
Condition 3:
Condition 4:
Condition 5:If there is no "OG" or "D" in the array formula returns Blank.

Excel Formula IF statement

I would really appreciate if you can help me on the excel formula logic. I am able to get the first part where I am able to display "1" in the check column if there is "Yes" in A,B,C columns and no values in either Amount 1, Amount 2 or Amount 3 columns (screenshot attached)
I also want to display "1" if there in "No" is A,B,C columns and a value in either Amount1, Amount2 or Amount 3 columns.
=IF(AND(E3="",F3="",G3="",OR(B3="Yes",C3="Yes",D3="Yes")),1,0)
How to add the below formula to above one
or IF(AND(E3<>"",F3<>"",G3<>"",OR(B3="No",C3="No",D3="No")),1,0)
=IF(OR(AND(E3= "",F3= "",G3= "",OR(B3="Yes",C3="Yes",D3="Yes")),
AND(E3<>"",F3<>"",G3<>"",OR(B3="No" ,C3="No" ,D3="No" ))),1,0)

How to find a specific text from a column that a set of comma separated values in Excel?

I have a column like this
Now I know the set of values. Like someone was asked about 'Sports' and he/she had the below choices:
Cricket
Tennis
Football
Others
Now the values that you see in any cell of the column apart from 'Cricket', 'Tennis' or 'Football' are entered as 'Others'
So I want the output in this manner that will only fetch what has been put as 'Others' and where it was not chosen it will be '0' (zero)
But if you see I was taking about 'Others' as an example. For this example, there is no such letter as 'Others', instead of there are 'I dont like any sports' or 'Playing sports was good at home' etc which can be anything followed by. So I want to show anything that doesn't match with 'Cricket', 'Football' or 'Tennis'
I'm a very novice at Excel and kind of doing this first time. Can anyone help what formula should I write at the starting of B column?
Enter this as a function in the first row in your B column and pull it down for all your rows:
=IF(A1="Others";A1;0)
If you pull it down correctly, then the row below it should read =IF(A2="Others";A2;0), rinse and repeat for all rows below. All cells in the B column should now either show "Others" or 0.
This is a simple IF statement in Excel and should be read as:
=IF(A1="Others";A1;0)
Or in pseudo-code:
IF A1 EQUALS "Others" THEN B1 EQUALS A1 ELSE B1 EQUALS 0
You can also replace the A1 and 0 in your formula by anything you like, e.g. you can set it to true and false by changing it to =IF(A1="Others";true;false).
I don't know what you are planning to use it for, but you can also just set a filter at the top row, and filter out every cell which does not contain "Others". When working with large Excel-files, filters are your friend.

in excel 2010 I want to count both "Yes" and "N/A" and not count a "No"

I am trying to count both "Yes" and/or "N/A" to populate a score. The three options are Yes, No and N/A. Currently the cells are set-up in list format thought the Data Validation on Excel. However, I can not get the cell to count either Yes and N/A. When i put in this formula:
=Countsif (B:B, "Yes", B:B, "N/A)
I get a zero, even though 3 of my cells are either a "Yes" or an "N/A". What am i doing wrong?
Do a sum of countif -
=sum(countif(B:B,"yes"),countif(B:B,"N/A"))
a countifs tries to match criteria with AND not OR - link
Can sum up the counts
=COUNTIF(B:B,"yes") + COUNTIF(B:B,"n/a")

Find something in column A then show the value of B for that row in Excel 2010

Basically my problem is that I have a string in one cell in excel, I then need to see if that string exists in another row (not one cell but the whole row) and if so then print the contents of another cell in the same row but in another column.
I will give a basic example:
Title Answer
Police 15
Ambulance 20
Fire 89
Now I need to scan the title column for, say, "Police" and then populate the cell with the value under Answer (in this case 15).
I cant just say IF(A2="Police";B2;"" as I need the scan the whole of the Title column.
I have tried using IF(COUNTIF(A$2:A$100;"Police"); which scans the contents of A2 to A100 for the string Police, and know how to make it print a constant (just put something after the ;) but cant work out how to make that "constant" a variable that changes depending on the found row. So if the COUNTIF found Police in cell A44 then the answer to my formula would be B44, the same as if it found Police in A62 then my formula should show B62
I hope this makes sense and that someone can help me :)
Note that I am using excel 2010 and need a normal formula as I can not use scripting for this document.
EDIT:
Here is what I have so far, note that the spreadsheet I am using is far more complex than the "simple" example I have in the question...
=IF(ISNUMBER(FIND("RuhrP";F9));LOOKUP(A9;Ruhrpumpen!A$5:A$100;Ruhrpumpen!I$5:I$100);"")
This is showing "RuhrP" in every answer where "RuhrP" is found in F9 and not the answer I want which should be that found in RuhrPumpen!I$5:I$100 where the cell index is the same as that for the A coloum where A9 was found. Again, sorry for the complexity I cant think of any better way to word it.
I note you suggested this formula
=IF(ISNUMBER(FIND("RuhrP";F9));LOOKUP(A9;Ruhrpumpen!A$5:A$100;Ruhrpumpen!I$5:I$100);"")
.....but LOOKUP isn't appropriate here because I assume you want an exact match (LOOKUP won't guarantee that and also data in lookup range has to be sorted), so VLOOKUP or INDEX/MATCH would be better....and you can also use IFERROR to avoid the IF function, i.e
=IFERROR(VLOOKUP(A9;Ruhrpumpen!A$5:Z$100;9;0);"")
Note: VLOOKUP always looks up the lookup value (A9) in the first column of the "table array" and returns a value from the nth column of the "table array" where n is defined by col_index_num, in this case 9
INDEX/MATCH is sometimes more flexible because you can explicitly define the lookup column and the return column (and return column can be to the left of the lookup column which can't be the case in VLOOKUP), so that would look like this:
=IFERROR(INDEX(Ruhrpumpen!I$5:I$100;MATCH(A9;Ruhrpumpen!A$5:A$100;0));"")
INDEX/MATCH also allows you to more easily return multiple values from different columns, e.g. by using $ signs in front of A9 and the lookup range Ruhrpumpen!A$5:A$100, i.e.
=IFERROR(INDEX(Ruhrpumpen!I$5:I$100;MATCH($A9;Ruhrpumpen!$A$5:$A$100;0));"")
this version can be dragged across to get successive values from column I, column J, column K etc.....
Assuming
source data range is A1:B100.
query cell is D1 (here you will input Police or Fire).
result cell is E1
Formula in E1 = VLOOKUP(D1, A1:B100, 2, FALSE)
I figured out such data design:
Main sheet:
Column A: Pump codes (numbers)
Column B: formula showing a corresponding row in sheet 'Ruhrpumpen'
=ROW(Pump_codes)+MATCH(A2;Ruhrpumpen!$I$5:$I$100;0)
Formulae have ";" instead of ",", it should be also German notation. If not, pleace replace.
Column C: formula showing data in 'Ruhrpumpen' column A from a row found by formula in col B
=INDIRECT("Ruhrpumpen!A"&$B2)
Column D: formula showing data in 'Ruhrpumpen' column B from a row found by formula in col B:
=INDIRECT("Ruhrpumpen!B"&$B2)
Sheet 'Ruhrpumpen':
Column A: some data about a certain pump
Column B: some more data
Column I: pump codes. Beginning of the list includes defined name 'Pump_codes' used by the formula in column B of the main sheet.
Spreadsheet example: http://www.bumpclub.ee/~jyri_r/Excel/Data_from_other_sheet_by_code_row.xls
Guys Its very interesting to know that many of us face the problem of replication of lookup value while using the Vlookup/Index with Match or Hlookup.... If we have duplicate value in a cell we all know, Vlookup will pick up against the first item would be matching in loopkup array....So here is solution for you all...
e.g.
in Column A we have field called company....
Column A Column B Column C
Company_Name Value
Monster 25000
Naukri 30000
WNS 80000
American Express 40000
Bank of America 50000
Alcatel Lucent 35000
Google 75000
Microsoft 60000
Monster 35000
Bank of America 15000
Now if you lookup the above dataset, you would see the duplicity is in Company Name at Row No# 10 & 11. So if you put the vlookup, the data will be picking up which comes first..But if you use the below formula, you can make your lookup value Unique and can pick any data easily without having any dispute or facing any problem
Put the formula in C2.........A2&"_"&COUNTIF(A2:$A$2,A2)..........Result will be Monster_1 for first line item and for row no 10 & 11.....Monster_2, Bank of America_2 respectively....Here you go now you have the unique value so now you can pick any data easily now..
Cheers!!!
Anil Dhawan

Resources