Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Does Qlik have any solution for building a central repository of expressions code and feeding it into dashboards?
By the way, in Qlik Cloud, there's also a way to create a central script - a script that you can use to add to several apps without having to write the same script to add the same variables into multiple apps.
Here's how that's done:
Step 01.
Go to the Create section and select the Script option.
Step 02.
Enter name and description for the script.
Step 03.
Click the Create button.
Step 04.
Go to the Editor tab to create the central script.
Step 05.
Write the central script.
Step 06.
Open an app that will need to use this script and in the Data load editor, click the Include Script button.
Step 07.
Select the script that you would like to use and click the Next button.
Step 08.
On the script preview screen, click the Insert button to insert centrally managed script.
That's all. Once the centrally managed script is added, it will look like this:
This way, if you'll ever need to change the script, you can change it in one location and it will update in all of the apps that use it.
This will not only centralize your expressions but also centralize the script that loads those expressions.
Central scripts can be created and used in an on-prem Qlik Sense as well, but the way to create and add a central script is different.
Hi @mgranillo !
I don't think there is anything out of the box that would do that. I remember seeing extensions that may assist with that.
In my own practice, ever since QlikView times, I'm storing expressions in CSV files and loading them into the app as variables. Then, the variables can be used around the app using $-sign expansion. I'm describing this process in detail in my book QlikView Your Business, and in my Qlik Expert Class.
A simplified example:
SET exp_Sales = 'sum(Sales)'
Measure Sales: $(exp_Sales)
Allow me to invite you to my Qlik Expert Class that I'll be teaching in Vienna, Austria on September 22-24. I will be teaching advanced data modeling, along with advanced scripting, performance optimization, and advanced aggregation and Set Analysis techniques. You will learn the most advanced Qlik methodologies that will help you solve tough problems like this one.
Cheers,
Oleg Troyansky
Loading expressions from a spreadsheet and storing them in variables is how I tend to centralize expressions as well.
If you're looking for an example of what that would look like, here's the script for it:
// load spreadsheet containing variable names and expressions
centralExpressions:
LOAD
Variable,
Expression
FROM [lib://howdash:DataFiles/centralExpressions.xlsx]
(ooxml, embedded labels, table is Sheet1)
;
// loop through each row in spreadsheet and create a variable with corresponding expression
For i = 0 to NoOfRows('centralExpressions') - 1
Let vVariableName = Peek('Variable', $(i), 'centralExpressions');
Let vExpression = Peek('Expression', $(i), 'centralExpressions');
Let $(vVariableName) = '$(vExpression)';
Next i
// cleanup
Let vVariableName = Null();
Let vExpression = Null();
Let i = Null();
Drop Table centralExpressions;
This will load data from a spreadsheet which look like this:
and create a variable for each row in the spreadsheet. The variables will then appear in whichever app that you add this script to. In the app the variables will look like this:
You can then, as Oleg suggested, write expressions that use these variables like this:
By the way, in Qlik Cloud, there's also a way to create a central script - a script that you can use to add to several apps without having to write the same script to add the same variables into multiple apps.
Here's how that's done:
Step 01.
Go to the Create section and select the Script option.
Step 02.
Enter name and description for the script.
Step 03.
Click the Create button.
Step 04.
Go to the Editor tab to create the central script.
Step 05.
Write the central script.
Step 06.
Open an app that will need to use this script and in the Data load editor, click the Include Script button.
Step 07.
Select the script that you would like to use and click the Next button.
Step 08.
On the script preview screen, click the Insert button to insert centrally managed script.
That's all. Once the centrally managed script is added, it will look like this:
This way, if you'll ever need to change the script, you can change it in one location and it will update in all of the apps that use it.
This will not only centralize your expressions but also centralize the script that loads those expressions.
Central scripts can be created and used in an on-prem Qlik Sense as well, but the way to create and add a central script is different.
These are all work arounds in my opinion. Very shocking to me that Qlik doesn't have a solution across any of their products at this point in time but I found this ideation entry that looks like it will solve the issue: https://ideation.qlik.com/app/#/case/273692?cpid=c2fdb833-bf1e-42bd-bfab-adcf731b50cb
It's on the roadmap too
I agree, they are workarounds. It would be so great if we had global expressions that we could import!
It’s exciting to hear that something like that is on the roadmap! I gave the idea a vote.