Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Qlik Script Sub KeepFields to Drop mass fields
Sub KeepFields(Fields,TableName)
Let n = NoOfFields('$(TableName)');
Set d = #;
For i = 1 to $(n)
Let f = FieldName($(i), '$(TableName)');
If Index('$(Fields)', ',$(f),') = 0 then
If '$(d)' = '#' then
Let d = '$(f)';
Else
Let d = '$(d),$(f)';
End if
End if
next
If '$(d)' <> '' then
Drop Fields $(d);
End if
End Sub
//Example:
//Call KeepFields(',CUSTOMER_ID,NAME,ADDRESS,PHONE,', 'Customer');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.