Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

User defined function in the script?

Hi,

is it possible to define a function into the QV script? If yes, a simple sample, please.

Thanks

3 Replies
IAMDV
Master II
Master II

pscorca69 - Please read the below post. I got it working with Variables and it is fantastic solution by Tim.

http://community.qlik.com/forums/t/43601.aspx

Cheers - DV

IAMDV
Master II
Master II

Is the above post helpful? Please share if you find more information...

johnw
Champion III
Champion III

Here's an example of creating a couple functions in the script using variables. It's also an example of building functions from an inline table, which isn't something you need, but hopefully you can recognize what's what and get the idea.

[Holidays]:
LOAD * INLINE [
Holiday
3/15/2010
3/10/2010
2/15/2010
1/1/2010
];

AllHolidays:
LOAD concat(num(Holiday),',') as AllHolidays RESIDENT Holidays;
LET customfirstworkdate = 'firstworkdate($1,$2,' & peek('AllHolidays') & ')';
LET customnetworkdays = 'networkdays($1,$2,' & peek('AllHolidays') & ')';
DROP TABLE AllHolidays;

Edit: A couple simpler examples from a sample currency conversion script:

LET money = 'money($1,only(CurrencyFormat),only(Decimal),only(Thousand))';
LET date = 'date($1,only(DateFormat))';