Created
May 1, 2017 20:40
-
-
Save ralfbecher/cd7201296a669424f45d798a9d5e38e9 to your computer and use it in GitHub Desktop.
Qlik Script Sub KeepFields to Drop mass fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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