Excel formula to return a value upon meeting criteria set for two columns

Faza Moyo

New Member
Joined
Nov 22, 2017
Messages
7
If values repeat in consecutive rows of a column and in the corresponding rows of the other column the values do not repeat then return zero(0) otherwise return one(1)

Unique IDDisease NameResults
12005CVD
12005CVD
13964RD
12345DIABETES
12345RD

<tbody>
</tbody>

Now I kindly request you to help an excel formula which will return 1 in the first two rows of the Results column and zeros(0) in the third up to fifth row of the Results column, despite Unique ID in the fourth and fifth row being the same. I am not able to do coding so help me with formula which are in the excel formula list.I use Microsoft excel 2007
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
In C2 control+shift+enter, not just enter, and copy down:

=IF(FREQUENCY(IF($A$2:$A$6=A2,ROW($A$2:$A$6)),IF(1-($A$2:$A$6=A2),ROW($A$2:$A$6)))>1,1,0)

Does this meet your requirements?
 
Upvote 0
Thank you Aladin,
However, the conditions are for the first two columns. To make it clear I have tried to give more explanation to this problem.

The value zero(0) or one(1) to be returned in the Results column is conditional to criteria set in the first two columns(Unique ID & Disease Name). The criteria are; if the consecutive values in Unique ID column are the same (eg. 12005 in the first two column) and Disease name in the corresponding column (Disease Name) are the same (eg CVD in the first two rows of the Disease Name), formula has to return 1, otherwise has to return zero.
 
Upvote 0
Thank you Aladin,
However, the conditions are for the first two columns. To make it clear I have tried to give more explanation to this problem.

The value zero(0) or one(1) to be returned in the Results column is conditional to criteria set in the first two columns(Unique ID & Disease Name). The criteria are; if the consecutive values in Unique ID column are the same (eg. 12005 in the first two column) and Disease name in the corresponding column (Disease Name) are the same (eg CVD in the first two rows of the Disease Name), formula has to return 1, otherwise has to return zero.

Control+shift+enter, not just enter, and copy down:

=IF(FREQUENCY(IF(($A$2:$A$6=A2)*($B$2:$B$6=$B2),ROW($A$2:$A$6)),IF(1-($A$2:$A$6=A2),ROW($A$2:$A$6)))>1,1,0)
 
Upvote 0
Thanks again.
I have used the formula, however; it returns zeros (0) to all 5 rows! I don't know where I make mistake because it was required to return zeros(0) in the third through fifth row and ones (1) in the first two rows.
This is how I have written the formula you had given me:
=IF(FREQUENCY(IF(($A$2:$A$6=A2)*($B$2:$B$6=$B2),ROW($A$2:$A$6)),IF(1-($A$1:$A$6=A2),ROW($A$1:$A$6)))>1,1,0) where column A is the column with Unique ID and column B is the column with Disease Name
Thank you for your continued support
 
Upvote 0
Have you applied control+shift+enter?

Control+shift+enter means: Press down the shift and the control keys at the same time while you hit the enter key. When done correctly, Excel itsel puts a pair of { and } around the formula in recognition.
 
Upvote 0
Hi,

Another approach :

Ctrl+Shift+Enter NOT just Enter

C2 =IF(SUM(--(A2&B2=$A$2:$A$6&$B$2:$B$6))>1,1,0)

ABC
1Unique IDDisease NameResults
212005CVD1
312005CVD1
413964RD0
512345DIABETES0
612345RD0

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Yes I have applied Control+shift+enter. I have pressed all three keys at the same time. The results returned are as explained above; all zeros(0)
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top