-1

Currently have the following excel table

enter image description here

I would like to do the following

I want to write a IF statement or something else which would do this:

if (the value in service 4 for company 1 is 1, and the value in service 1 for company 1 is also 1, then copy the value 1 to a new column)

how can one do this in excel ?

If the matching does not exist then copy 0 or nothing

Data Science
  • 79
  • 2
  • 12

2 Answers2

2

How about:

=IF(AND(B2=1,E2=1)=TRUE,1,0)

as based on : enter image description here

Or you could use:

=IF(SUM(B2,E2)=2,1,0)

which achieves the same thing.

Solar Mike
  • 7,156
  • 4
  • 17
  • 32
  • you don't need the =True part. And(B2-1,E2=1) is enough – Forward Ed Jul 26 '18 at 13:06
  • While this is technically a functional answer, I do kind of suspect that the data OP provided here was just an example and you have to account for the fact that the data can contain more than a single row per company (hence even in his example, one instance of company 1 shoulde result in true and one in false (1) and (0). It's not really a knock against your answer, but more of lacking details in the original question – Samuel Hulla Jul 26 '18 at 13:06
  • @ForwardEd, good point and quite right, but I did it to make it clear for the OP. – Solar Mike Jul 26 '18 at 13:15
  • Basically, your answer should be fine. Here is some shorthand: =AND(B2=1,E2=1)*1 or to make it unclear what is going on =(B2=1)*(E2=1)*1 – FocusWiz Jul 26 '18 at 13:21
  • I take that back since any answer is dependent on what the new version of the question becomes. – FocusWiz Jul 26 '18 at 13:37
0

Assuming you put the company name that you want to check in G1 you could use the following

=--AND(VLOOKUP(G1,$A$2:$E$5,2,0)=1,VLOOKUP(G1,$A$2:$E$5,5,0)=1)

For you results of just needing 1 or 0 the above would work as true will evaluate to 1 and false will evaluate to 0.

However if you wanted some other result other than 1 and 2 I would change the formula to:

=IF(AND(VLOOKUP(G1,$A$2:$E$5,2,0)=1,VLOOKUP(G1,$A$2:$E$5,5,0)=1),"True Result","False Result")
Forward Ed
  • 9,484
  • 3
  • 22
  • 52
  • Hi Ed, I get the feeling we are trying to answer a question that is about to be changed as per the OP's comments... – Solar Mike Jul 26 '18 at 13:20