Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I´d like to know how can I do to get a '0' if a value doesn´t exist in a field and a '1' if the value exist.
For example, I have this table:
T1:
LOAD * INLINE [
F1
'a'
'a'
'a'
'b'
'c'
];
And I´d like to know if 'z' value is in the F1 field, getting a '1' or a '0' if the value exist or not.
I´ve tried this
tmp:
LOAD COUNT(DISTINCT F1) as Found RESIDENT T1 WHERE F1='z';
LET value= peek('Found',0,'tmp');
But the value is NULL and not '0' when 'z' is not in the table.
Thanks a lot.
You can change your expression to:
LET value= NoOfRows('tmp');
An easier way might be to skip creating the tmp table and use fieldIndex().
LET value = if(fieldIndex('F1', 'z') > 0, 1, 0);
You can change your expression to:
LET value= NoOfRows('tmp');
An easier way might be to skip creating the tmp table and use fieldIndex().
LET value = if(fieldIndex('F1', 'z') > 0, 1, 0);
Thanks a lot.