Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I am trying to write a query like below:
TableA:
LOAD
floor(RAND()*17)+10 as Test,
1 as Counter
AutoGenerate 23;
If($(vDropField)=1, Drop Field Counter, False);
Basically I want to drop the field is the vDropField variable contains 1, else don't drop the field.
It doesn't work when I write it. Any idea how to do this please?
Hi Sunny,
I seem to have solved it.
Strange behaviour initially, I had an InputBox with the variable value but it gave me the above error.
So then I went to Variable Overview and assigned a 1 to the variable and reloaded. And it ran fine and dropped the field.
That is strange, I would have expected inputbox to have worked the same way as variable view. Are you sure you were using the right variable in the inputbox? Can you check making changes to the value (may be assign 2) through the input box and see if that changes the value in variable overview? Trying to understand where the disconnect is.
And have you actually confirmed the input value in your input box by either clicking another object or pressing Enter before starting the reload?
Hi,
Try like this
LET vDropField = 1; //or replace with your expression
TableA:
LOAD Floor(Rand() * 17) + 10 as Test,
1 as Counter
AutoGenerate 23;
If vDropField = 1 then
DROP Field Counter;
ENDIF
Seems to be working in the attached file
Hi guys,
What I want to do is get the script to load the Counter field if vDropField does not evaluate to 1.
So far this code works if it evaluates to 1:
TableA:
LOAD
floor(RAND()*17)+10 as Test,
1 as Counter
AutoGenerate 23;
If $(vDropField) = 1 then
DROP Field Counter;
ENDIF
How can I put an ELSE in to load the Counter field if vDropField does not evaluate to 1?
In essence what I am trying to do is allow the user to say load the field or not.
Let vCounterLoad = If( $(vDropField) = 1,'',', 1 as Counter');
TableA:
LOAD
floor(RAND()*17)+10 as Test
$(vCounterLoad)
AutoGenerate 23;
May be this:
TableA:
LOAD
floor(RAND()*17)+10 as Test,
1 as Counter
AutoGenerate 23;
If $(vDropField) <> 1 then
DROP Field Counter;
ENDIF
another solution
TableA:
LOAD
floor(RAND()*17)+10 as Test,
1 as Counter
AutoGenerate 23;
If $(vDropField) = 1 then
DROP Field Counter;
ELSE
Drop table TableA;
TableA:
LOAD
floor(RAND()*17)+10 as Test,
1 as Counter
AutoGenerate 23;
ENDIF
Hi,
Try like this for else
TableA:
LOAD
floor(RAND()*17)+10 as Test,
1 as Counter
AutoGenerate 23;
If $(vDropField) = 1 then
DROP Field Counter;
ELSE
// Else statements goes here
ENDIF