0

I want to create a new column based on a range of columns(GAP1-GAP5). I wanted to use something like this:

IF FIND(GAP1-GAP5,'New Start') THEN FILTER_NewStart=1

but got an error so had to use this:

IF FIND(GAP1,'New Start') OR FIND(GAP2,'New Start') OR FIND(GAP3,'New Start') 
  OR FIND(GAP4,'New Start') OR FIND(GAP5,'New Start') THEN FILTER_NewStart=1;

Do I need to use a loop or can I use a function for a range of columns to achieve this?

AdamO
  • 4,283
  • 1
  • 27
  • 39
  • An `array` statement will probably work faster than the accepted answer, if speed is of any concern. – AdamO Mar 07 '19 at 22:10

3 Answers3

0

Try concatenating them and using find on the variable instead.

if(find(cat(of GAP1-GAP5), 'New Start') ) then FILTER_NewStart = 1;
Stu Sztukowski
  • 10,597
  • 1
  • 12
  • 21
0

Sounds like you want to use the WHICHC() function to find the first variable in a list of variables that equals a specific value. If none have it then the result is zero.

FILTER_NewStart=0 ne whichc('New Start',of GAP1-GAP5);

FIND() is for locating a specific substring in a longer string and so cannot work on many variables at once.

Tom
  • 47,574
  • 2
  • 16
  • 29
0

@Tom whichc() is a good idea, whereas it doesn't work if GAP1-GAP5 just contain but not equal to 'New Start'. find() would be a better anwser in this situation.

whymath
  • 1,262
  • 9
  • 16