cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
UserID16644
Level V

Run functions when column is not empty

Hi all,

 

I have a function where I needed it running when and only the column is not blank. How can I properly check if the column is not blank and run the function, I tried isMissing() but is not working properly. 

 

Sample function: 

exsqr = Function( {x}, x * x );
exsqr( 5 );

 

So it would look like something like this:

exsqr0; //function1

if (isMissing(Column1),  //if Column1 has values, it should run the function, else, skip this function and proceed to function3

exsqr); //function2

exsqr1; //function3

1 REPLY 1
jthi
Super User

Re: Run functions when column is not empty

You could use Col N Missing in combination with N Rows or Col Number to check if there are anything else besides missing values. Below are some ideas:

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(3),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([., ., .])),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([1, ., 3]))
);

Show(Col N Missing(:Column 1));
Show(Col N Missing(:Column 2));
If(N Rows(dt) - Col N Missing(:Column 1) > 0,
	Show(:Column 1 << get values);
);

Show(Col Number(:Column 1));
Show(Col Number(:Column 2));
If(Col Number(:Column 2) >= 0,
	Show(:Column 2 << get values);
);
-Jarmo