Skip to content

Instantly share code, notes, and snippets.

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)';
Let d = '$(d),$(f)';
End if
End if
If '$(d)' <> '' then
Drop Fields $(d);
End if
End Sub
//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