Setting value if two conditions are true - excel

I have a table that contains three columns. I need to set a value in column C that depends on column A and B. If all the values in column B are the same for a fixed value in column A then each row in column C needs to say "Pass" otherwise "Fail".
In the example screenshot the status is "Pass" for all values with ID = 2 because all values in the column "Name" are the same e.g. C
Example Table

A simple IF and COUNTIFS:
=IF(COUNTIFS(A:A,A2,B:B,"<>"&B2)=0,"Pass","Fail")

Without VBA
formula in C2 and copy down
(Maybe you have to replace the semicolon with comma)
=IF(COUNTIF($A$2:$A$11;A2)=COUNTIFS($A$2:$A$11;A2;$B$2:$B$11;B2);"Pass";"Fail")

Related

Excel Column B has duplicates and only 1 row has value in Column A for each set of duplicates in B, return something to identify there is a match

Excel Formula (non VBA preferred)
Column B has duplicates and only 1 row has value in Column A for each set of duplicates in column B.
Need to return "something"/True/False/wtvr in column C to identify there is a value in A and B anywhere for the duplicate values in column B, leaving items without something in Column A blank.
Pretty easy using COUNTIFS:
=IF(COUNTIFS(B:B,B2,A:A,"<>")>0,"something","")
If column A contains a formula that returns a null string (""), something like:
=IF(SUMPRODUCT((B$2:B$18=B2)*(LEN(A$2:A$18)>0))>0,"something","")
where B$2:B$18 and A$2:A$18 represent the ranges with data.

I am checking to see if any values in column C match with values from column B

I need preferably a formula or macro in excel 2013 to do the following:
Check if any given values in column C match with values from column B.
If they do I want to take the corresponding value from the same row in column A as the matched items in column B.
I then want to take those values from column A and put them in the same rows in column D.
Specifically, I am checking to see if any ID's in column C match with ID's from column B. If they do I want to take the corresponding city ID from column A in the same row as the matched items in column B.
I then want to take those values from column A and put them in the same rows in column D.
I used this formula =VLOOKUP(C6; A2:B14; 1; FALSE) but it returns #N/A
VLOOKUP will always use the first column as lookup_array. But in your case, you are using the second column for lookup_array, and wanting to return the value in the first column. So VLOOKUP is not appropriate.
Depending on your version of Excel, you could use INDEX(MATCH or XLOOKUP:
=INDEX($A$2:$A$14,MATCH(C2,$B$2:$B$14,0))
=XLOOKUP(C2,$B$2:$B$14,$A$2:$A$14)

How to compare columns A/B, and return value from column A that does not match B

I am running into an issue trying to compare values from column A and B. The end result is to have any value in column A that does not have a match in column B, to appear in column C.
The formula I am using is simple and just =IF(A2=B2, "Y", "N")
My issue is that I am unsure of how to compare the entire A column to the entire B column for matches and not row by row. I only want to see values returned in column C that are in Column A, but not in Column B.
There are about 150,000 rows of data here.
You can do that using a vlookup.
Formula for column C2 (apply it for entire column C) - =IF(ISNA(VLOOKUP(A1,B$1:B$13,1,FALSE)),A1,"")
You can modify the table range "B$2:B$13" depending on the actual table.
I think this will get you what you want:
=IF(COUNTIF(B:B,A1)=0,A1,"")
Edit:
Here is an example of the results I am getting.

How to concatenate a column value based on another column value in excel?

I have sheet like this :
How can I concatenate values in column B based on value in column A.
Values corresponding to ID 1.1.1 are of B2:B5
Similarly, values for ID 1.1.2 are of B6:B8 and so on..
Its like it start from first id, lookup until next id, all values in column B until next Id in column A is concatenated
the result should be like this : 2,3,4,5 in single cell of column D
I am not sure if this would solve your purpose, but you can keep concatenating values till the value in column A is same and use the last value.
Assuming the case you provided, paste the formula =IF(A2<>"",B2,D1&", "&B2) in cell D2 and copy throughout the column. You can additionally create a flag for changes in column E using =IF(A2<>"",1,"") in cell E2. The results would be like this.
It's still not quite clear, what you are trying to achieve, but to simply concatenate columns with a comma as separator, you can try something like the following:
In column d2 (or column d5), type in the following formula
=B2&","&B3&","&B4&","&B5
That should get you in the right direction.

Nested IF and ISBLANK formula

I need help with a nested IF and ISBLANK formula. Here is the scenario:
There are three columns: A, B and C. All three are dates.
I want to retrieve the value of column A in column D (direct value). if Column A is blank, retrieve Column B value, if Column B is also blank retrieve Column C value.
Addition to this if column A has year 2015/2016 consider that cell as Blank and retrieve Column B/C.
How do I tackle this scenario?
For your first bit:
=IF(ISBLANK(A1),IF(ISBLANK(B1),C1,B1),A1)
Then to add in the 2015/2016 check on A. This:
=IF(OR(ISBLANK(A3),AND(A3>=DATE(2015,1,1),A3<=DATE(2016,12,31))),IF(ISBLANK(B3),C3,B3),A3)
A different interpretation:
=1*TRIM(LEFT(IF(A1="2015/2016","",A1)&B1&C1,5))

Resources