Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
RedSky001
Partner - Creator III
Partner - Creator III

Formatting numbers with VBscript function

I'd like to write a VBscript function to format numbers and use it within chart expressions.  Could someone provide the correct syntax
(Appreciate the below code includes num() which is not vb script)

function formatNumber(parameter)

if(parameter > 1000000
or $parameter < -1000000
,num((parameter / 1000000),'#,##0 Mil')
,if(parameter > 1000
or parameter < -1000
,num((parameter / 1000),'#,##0 K')
,num($1,'#,##0')
))

end Function

Regards

Mark

Message was edited by: msheraton After reading QlikView Automation Reference it appears user defined functions cannot be called in Expressions.  So I'll have to do this another way...

3 Replies
Not applicable

What is a workaround to this, if i want to only use VBScript ?

MarcoWedel

Hi Mark,

you could try using a parameterized variable.

regards

Marco

MarcoWedel

might be a bit late

but maybe someone is searching for something like this:

QlikCommunity_Thread_38556_Pic1.JPG.jpg

QlikCommunity_Thread_38556_Pic3.JPG.jpg

SET vSize = Div(Log10($1),3);

SET vFormatNumber = Dual(Num($1/Pow(10,3*$(vSize($1))),'#,##0')&' '&Pick($(vSize($1)),'K','Mil','Bil','Tril'),$1);

LOAD *, $(vFormatNumber(parameter)) as paramFormat;

LOAD pow(10,Rand()*14) as parameter

AutoGenerate 30;

regards

Marco