Create a variable conditioned on two others

daniel3141

New Member
Joined
Nov 27, 2017
Messages
2
Inmay data I have two columns: organisation Code and flag, I want to create a newvariable based on these two. The flag column contains either 0 or 1.

Thesame organisation code can appear many times in the organisation code column, but if there areone or more examples of an organisation code having the number 1 in the flagcolumn, I want the new variable to be 1 in all cases for this organisation even ifthe same organisation is followed by 0 in the flag column in some cases.

OPX 0
OPX 0
OPX 1
OPX 0

So in the above example, the new variable will be a 1 for all cases of organisation code OPX, because there is at least one example of this organisation being followed by 1 in the flag column.

Doesanyone know how to do this within a formula?<o:p></o:p>
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I would use a countif formula in a header cell on the flag column - so if it is column B - countif($B:$B,1) - which will count all instances of the value 1
Then I'd set a single hidden cell using an if statement. So if your countif formula is in C1 I'd use if(B1>0,1,0)
Then set all values in your third variable column to refer to this single cell as they'll all be either 0 or 1 (if I've understood you correctly)
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,537
Members
449,088
Latest member
RandomExceller01

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