Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for
Did you mean:
Contributor III

## Custom Function Creation

How can I create my own Function in Qlik - I having to repeat this logic over and over?
=Num(Sum(population_baseline_pop_psd)*1000, vDecimalTwoPlaces, vDecimalSep, vThousandSep)

Where vDecimalTwoPlaces, houses 2 number formats based on the language selected. Similary for the Seperators.
I want to make it so that I can do something like:
SuperNum2(Sum(population_baseline_pop_psd)*1000)

Where SuperNum2 - has all these attributes set for cleaner code: vDecimalTwoPlaces,, vDecimalSep, vThousandSep

Labels (1)
• ### expression

4 Replies
Specialist

You have to create a new variable called "SuperNum2" containing
=Num(\$1, vDecimalTwoPlaces, vDecimalSep, vThousandSep)

Contributor III
Author

vNumTwo=vDecimalTwoPlaces

Specialist

Yes, the variable will be seen as invalid by QS.
Else, sorry, I have done a mistake in my copy/paste, the equal should not be in the variable definition.
So, you define SuperNum2 with Num(\$1, vNumTwo, vDecimalSep, vThousandSep)
Then, you use it with \$(SuperNum2(Sum(population_baseline_pop_psd)*1000))

Creator III

try this

set vDecimalTwoPlaces='#,###.00';
set vDecimalSep='.';
set vThousandsep=',';
set SuperNum2=num(\$1,'\$(vDecimalTwoPlaces)','\$(vDecimalSep)','\$(vThousandsep)');
Tab:
load *,\$(SuperNum2(Value)) as num;