Hi, I would like to create a function to scramble a few fields. A few questions:
1. Should I use Sub for Function key word? See below example, which don't have detailed logic.
Sub Scramble (field)
Scramble = UCase(field)
2. Can this function be placed in a block within the script editor?
3. How do I call this function? I called this function using below script, but it failed. Any suggestions?
Scramble(ContactName) AS Name
I have to scramble the text string in the SQL function, but would really like to know how to create and call function in Qlik.
A simple working example is most helpful. I am struggling to find such a sample, as there is very limited resources on web.
Thanks for your time!
You can set a dynamic variable. For example;
Set vFirstXLetters = mid($1,1,len($2))
After you declare this variable in script editor, you can use this variable like any function.
=$(vFirstXLetters('qliksense',1,'qlik') this will return 'qlik' as a result.
And you can use this variable in script editor.
set vOmitLetters = mid($1,len($2)+1,len($1)); load *, $(vOmitLetters(country,prefix)) as CountriesWithoutPrefix inline [ country, prefix germany,ger england,eng sweden,swe ]
I know the example is pretty much simple but it should be your starting point.
Thank you for the answer. However, how can I set up a function in the editor (like yours vFirstXLetters) and then repeatedly use this function in tables and charts?