Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
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
Highlighted
Luminary
Luminary

User defined function in the script?

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

Highlighted
Luminary
Luminary

User defined function in the script?

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

Highlighted
MVP
MVP

User defined function in the script?

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))';