Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
You have to create a new variable called "SuperNum2" containing
=Num($1, vDecimalTwoPlaces, vDecimalSep, vThousandSep)
vNumTwo=vDecimalTwoPlaces
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))
try this
set vDecimalTwoPlaces='#,###.00';
set vDecimalSep='.';
set vThousandsep=',';
set SuperNum2=num($1,'$(vDecimalTwoPlaces)','$(vDecimalSep)','$(vThousandsep)');
Tab:
load *,$(SuperNum2(Value)) as num;
load * inline
[ Value
100.18
10000
28837.1
];