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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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!

Labels (1)
1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

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.

View solution in original post

4 Replies
jagan
Partner - Champion III
Partner - Champion III

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.

Not applicable
Author

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

jagan
Partner - Champion III
Partner - Champion III

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.

Not applicable
Author

Yes, I found out...

Thanks, it works like a charm!

/Kim