
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using a variable as a global expression and putting it outside QV applications
Hi.
I have a solution that - as I see it - is pretty neat.
In a lot of applications I present the same KPI's. I build it so that I make a QVD file containing all relevant metrics (for instance no. calls, total handling times, etc.). I load these into different applications, and in different objects I calculate the KPI's based on the metrics. That is, I have defined what expressions that are used in which calculations, and by a long if statement, I ask QlikView to calculate the KPI values distributed on different dimensions.
This works really good, but for the ease of it, I put the long if statement into a variable and then calls this in the objects.
My question is, whether anyone knows whether or not you can put this variable into the load script of the applications. I am think using something like
LET Value = .... (if statement).
But the thing is that it contains a lot of ' and so one that the load script misinterpret.
So, I am think - also to have only one place to maitain this if statement - to put the if statement into a type of include file... (qv script file .qvs).
But does anyone know how to do this?
If so, how do I make the script of the 'if' statement so that QlikView automatically loads the if statement as a variable in the aplications including the include file (.qvs)?
Cheers!
- Tags:
- qlikview_scripting
Accepted Solutions

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Instead of LET use SET, just pasted this in text file and save with QVS extension.
SET vTemp = if(KPI = 'Abandoned rate',
SUM(
{<
Metric = {'Abandoned contacts'}
>}
Value )
/
SUM(
{<
Metric = {'Offered contacts (calls)'}
>}
Value )
,
if(KPI = 'Monitorering - antal'
,
SUM(
{<
Metric = {'Monitoring - total'}
>}
Value )
,
if(KPI = 'Monitorering - bestået'
,
SUM(
{<
Metric = {'Monitoring - passed'}
>}
Value )
/
SUM(
{<
Metric = {'Monitoring - total'}
>}
Value )
)))
And use =$(vTemp) as an expression.
Hope this helps you.
Regards,
Jagan.

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Save you variable script in a file and save it with QVS extension.
And then in Edit Script -> Edit tab -> Include and select your QVS file, then you will get something like
$(Include=filename.qvs).
This loads your variable every time you load QVW file.
Regards,
Jagan.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, but it doesn't work as I want it...
For instance, if I have a variable that looks like this:
if(KPI = 'Abandoned rate'
,
SUM(
{<
Metric = {'Abandoned contacts'}
>}
Value )
/
SUM(
{<
Metric = {'Offered contacts (calls)'}
>}
Value )
,
if(KPI = 'Monitorering - antal'
,
SUM(
{<
Metric = {'Monitoring - total'}
>}
Value )
,
if(KPI = 'Monitorering - bestået'
,
SUM(
{<
Metric = {'Monitoring - passed'}
>}
Value )
/
SUM(
{<
Metric = {'Monitoring - total'}
>}
Value )
)))
And I want this to be in a variable of my QV document. How should I script this in a .qvs file in order for the LET XX = $(Include=XXXX.qvs) to work?
/Kim

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Instead of LET use SET, just pasted this in text file and save with QVS extension.
SET vTemp = if(KPI = 'Abandoned rate',
SUM(
{<
Metric = {'Abandoned contacts'}
>}
Value )
/
SUM(
{<
Metric = {'Offered contacts (calls)'}
>}
Value )
,
if(KPI = 'Monitorering - antal'
,
SUM(
{<
Metric = {'Monitoring - total'}
>}
Value )
,
if(KPI = 'Monitorering - bestået'
,
SUM(
{<
Metric = {'Monitoring - passed'}
>}
Value )
/
SUM(
{<
Metric = {'Monitoring - total'}
>}
Value )
)))
And use =$(vTemp) as an expression.
Hope this helps you.
Regards,
Jagan.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I found out...
Thanks, it works like a charm!
/Kim
