Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Is it possible to have optional parameters in an expression stored in a variable?
vSKUcount =
Count(
{<
[Year]={$1},
[Type]={$2} <<< ?Optional?
>}
Distinct [SKU ID])
$(vSKUcount(2022,?Optional?))
Many thanks,
NSB
You can't have optional parameters in the typical meaning, but you can pass an empty string for a skipped parameter and test the length. Like this:
vSKUcount =
Count(
{<
[Year]={$1}
$(=if(len($2),',[Type]={$2}', ''))
>}
Distinct [SKU ID]);
$(vSKUcount(2022,''))
or
$(vSKUcount(2022,mytype))
-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com
I may have a solution for this, I have have used the wildcard character * for any parameters that I would like to be optional, hopefully returning all possible selections which effectively does what I need.
If any body knows any potential issues with this or a more elegant solution, please do let me know.
Many thanks
NSB
vSKUcount =
Count(
{<
[Year]={$1},
[Type]={$2} <<< Optional?
>}
Distinct [SKU ID])
$(vSKUcount(2022,*))
You can't have optional parameters in the typical meaning, but you can pass an empty string for a skipped parameter and test the length. Like this:
vSKUcount =
Count(
{<
[Year]={$1}
$(=if(len($2),',[Type]={$2}', ''))
>}
Distinct [SKU ID]);
$(vSKUcount(2022,''))
or
$(vSKUcount(2022,mytype))
-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com
Nice one. Thank you. 👍