Discussion Board for collaboration on QlikView Scripting.
I am trying to write a query like below:
floor(RAND()*17)+10 as Test,
1 as Counter
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?
Go to Solution.
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:
LOAD Floor(Rand() * 17) + 10 as Test,
1 as Counter
If $(vDropField) = 1 then
DROP Field Counter, False;
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;
When I try it:
If $(vDropField)= 1 then
DROP Field Counter;
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?
Add this at the top of your script just to check if $(vDropField) is showing one or not.
If $(vDropField)=1 then
Drop Field Counter;
else TRACE "False"
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?
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 ......