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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
mgranillo
Specialist
Specialist

Expressions Repository

Does Qlik have any solution for building a central repository of expressions code and feeding it into dashboards? 

Labels (1)
1 Solution

Accepted Solutions
howdash
Creator II
Creator II

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.

01. create central script.jpg

 

 

Step 02.

Enter name and description for the script.

 

Step 03.

Click the Create button.

02. name the script.jpg

 

Step 04.

Go to the Editor tab to create the central script.

03. script overview.jpg

 

Step 05.

Write the central script.

04. script populated.jpg

 

Step 06.

Open an app that will need to use this script and in the Data load editor, click the Include Script button.

05. add script.jpg

 

Step 07.

Select the script that you would like to use and click the Next button.

06. select script.jpg

 

Step 08.

On the script preview screen, click the Insert button to insert centrally managed script.

07. script preview.jpg

 

That's all. Once the centrally managed script is added, it will look like this:

08. script added.jpg

 

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.

View solution in original post

5 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

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

 

Ask me about Qlik Sense Expert Class!
howdash
Creator II
Creator II

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:

howdash_0-1755625969719.png

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:

howdash_1-1755626050148.png

You can then, as Oleg suggested, write expressions that use these variables like this:

howdash_2-1755626206465.png

 

howdash
Creator II
Creator II

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.

01. create central script.jpg

 

 

Step 02.

Enter name and description for the script.

 

Step 03.

Click the Create button.

02. name the script.jpg

 

Step 04.

Go to the Editor tab to create the central script.

03. script overview.jpg

 

Step 05.

Write the central script.

04. script populated.jpg

 

Step 06.

Open an app that will need to use this script and in the Data load editor, click the Include Script button.

05. add script.jpg

 

Step 07.

Select the script that you would like to use and click the Next button.

06. select script.jpg

 

Step 08.

On the script preview screen, click the Insert button to insert centrally managed script.

07. script preview.jpg

 

That's all. Once the centrally managed script is added, it will look like this:

08. script added.jpg

 

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.

mgranillo
Specialist
Specialist
Author

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

howdash
Creator II
Creator II

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.