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?
Try
LET vDropCustomerGroup = If( '$(vDropCounterField)' = 'Yes','',', ApplyMap(''Customers_Map'',CustomerCode, ''Not Found'') as CustomerName');
Note the use of two single quotes as escape character within the ApplyMap()
May be like this:
TableA:
LOAD Floor(Rand() * 17) + 10 as Test,
1 as Counter
AutoGenerate 23;
If $(vDropField) = 1 then
DROP Field Counter, False;
ENDIF
You can keep to the example in the HELP:
if $(vDropField) =1 then; drop field Counter; end if;
edit:this should also work
if vDropField =1 then; drop field Counter; end if;
Hi Sunny,
When I try it:
TableA:
LOAD
floor(RAND()*17)+10 as Test,
1 as Counter
AutoGenerate 23;
If $(vDropField)= 1 then
DROP Field Counter;
ENDIF;
I get the following error message:
Did I miss something?
I have created a Input Box in the UI called vDropField which has value of 1 to test it.
Can you add a Trace statement for your variable?
TRACE $(vDropField);
Exit Script;
Add this at the top of your script just to check if $(vDropField) is showing one or not.
try
If $(vDropField)=1 then
Drop Field Counter;
else TRACE "False"
ENDIF
Hi Sunny,
It doesn't come through in the script when I check the Variables tab.
Can you check variable overview to see if you can see 1? Also can you make sure you have not mis-spelled or made a typo with the upper case lower case?
Hi Swuehl,
The first code doesn't run and throws the same error as reply to Sunny above.
And second code runs but I still have the Counter field available even though vDropField variable carries 1.
Where do you check this variable tab?
You should set the vDropField variable to 1 (and not to an expression like =If( A= B, 1) ) and check the correct case sensitiv spelling in all places.
For example, in the script:
Set vDropField = 1;
...
If vDropField = 1 ......