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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
NoNameFound
Contributor III
Contributor III

Using parameters in script functions for set expressions

Hello everyone, 

I've stumbled across this recently when I was searching for a way to create functions in Qlik Sense that return a value: 
https://techbuilders.info/blog/build-and-use-qlik-load-script-functions.html
This article goes over how dollar-sign expansion can be used to create custom functions that return a value (in contrast to SUB and CALL, which don't return anything).
I imagine the $1-parameter might clash with the set-identifier in the set expression (https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/ChartFunctions/Se..., see set-identifiers). 

I would love to know wether or not it is possible to build a set-expression in a similar way to what the author of the article did with regular math operations. Unfortunately it's not possible to comment under the post, otherwise I would've asked the original creator. 

In short form:
I would love to know if I can build a set-expression that takes a parameter (just like in the blog post), so I don't have to re-write the same expression multiple times when I only need to change one tiny detail about the expression each time.

Best regards

Labels (4)
3 Replies
rafaelencinas
Partner - Creator II
Partner - Creator II

Hi @NoNameFound !

I did it in the past, but now we have a new Feature, you can Apply Set Analysis over Master Items !

For example:

You have a Master Item name "Sales Master Item" and its formula is  Sum(MySales)

You can create another Master Item like this:

Name : Sales Region B 

Formula:

{<Region = {'Region B'} >}

[Sales Master Item]

 

PS

When you create dynamic texts to use Formulas in Expression it gets so slow to resolve the values.

Bye!

 

 

 

 

Senior Qlik Architect
Cobra, Stallone, "You're a problem and I'm the solution"
NoNameFound
Contributor III
Contributor III
Author

Hey Rafael, 

thank you for the quick reply (again)!

I'll give it a try!
Yet I ask myself if this can also be done without the use of master items, rather doing everything in the data load editor? In the meantime I've found out that set expressions can not make use of the parameters in the form of $1, $2 etc. as they are confusable with the set-identifiers. 

Best regards

marcus_sommer

In general it's possible to apply such logic but the how-to depends on the use-case. Means combining n parameters horizontally is rather simple but trying to nest parameters could be very hard.

In a lot of scenarios it's not very sensible because these variables don't simplify the tasks - quite often the opposite happens. Before going this way I suggest to consider to rethink the wanted UI because a proper data-model which contains the essential logic within the dimensionalities which leads in the end to just a few rather simple sum/count() fulfilled usually all requirements - and the user selects the wanted views. The less hard-coded stuff controlled by any magic is applied the better will be the usability:

Let the User Select - Qlik Community - 1463978