Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.


Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Optional Argument in Sub or Function

Using QV10 SR3.  Can you create a Function or Sub with an optional argument?  For example, can I create a Function like:

Function AddEmUp (a, b, optional c)

  AddEmUp = a + b + c

End Function

Here, the argument c is optional...so it works if I pass it two or three arguments.

2 Replies

Optional Argument in Sub or Function

You can create a function variable (dollar sign expansion with arguments), e.g.

Define in the script:

Set vDateDiff = if(len($2)=0, today(), $2) - $1;

Then you can call vDateDiff with one or two arguments (second argument defaults to today()):




Re: Optional Argument in Sub or Function