Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis question/problem

Hi there,

I have a Set Analysis question/problem that I'm trying to solve.

In my chart I have the following calculation :

SUM({<DateWeek={$(=MAX(Week(QuestionaireDate))-1)} Aantal)

This works fine in my chart where it shows me the total number for the previous week based on the selected week. I would like to make this a variable so in my script I have put the following statement after the SET.

SUM({<DateWeek={$(=MAX(Week(QuestionaireDate))-1)} >} Aantal)

But when I select the variable in de Expression Editor it gives me the following formula:

SUM({<DateWeek={}>} Aantal)

So the formula gets lost so probably calculation is wrong. My question is how to get this in the script in a variable.

I tried several things like

SUM({<DateWeek={ ' $(=MAX(Week(QuestionaireDate))-1) ' } >} Aantal) But this gives me

SUM({<DateWeek={''}>} Aantal)

And even tried this one

SUM({<DateWeek={ " $(=MAX(Week(QuestionaireDate))-1) " } >} Aantal) But this gives me

SUM({<DateWeek={""}>} Aantal)

The last thing I tried was this one

Create a variable called vPreviousWeek with expression SET vPreviousWeek = $(MAX(Week(QuestionaireDate))-1) and then the expression for another variable

SUM({<DateWeek={$(vPreviousWeek)} >} Aantal) But this gives me

SUM({<DateWeek={} Aantal)

Can someone please help me out? I love the possibilities of Set Analysis but it would be nice if it is possible to use the above one. Simply set I want to put my Set Analysis expression in a variable where in the expression a Max week is calculated based upon the selected week in de QV application. Should not be so difficult I thought but it seems rather extremely difficult to get it working outside of a chart.

Greetings,

Marc

1 Solution

Accepted Solutions
Gysbert_Wassenaar

What's happening is that when setting the variable qlikview tries to evaluate the part of your expression that starts with $. Since that returns nothing you get the result you see. You can try it this way:

LET variable = 'SUM({<DateWeek={" ' & '$' & '(=MAX(Week(QuestionaireDate))-1) " } >} Aantal)';


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

What's happening is that when setting the variable qlikview tries to evaluate the part of your expression that starts with $. Since that returns nothing you get the result you see. You can try it this way:

LET variable = 'SUM({<DateWeek={" ' & '$' & '(=MAX(Week(QuestionaireDate))-1) " } >} Aantal)';


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert,

thanks for the reply. Unfortunately it still does'nt work. It gives me now

SUM({<DateWeek={"$(=MAX(Week(EnqueteDatum))-1) " } >} Aantal) als value in my chart for every row and it is not calculating the answer.

Oeps, forgot the change SET to LET...I'm almost there. It now gives

SUM({<DateWeek={"49" } >} Aantal)

Greetz,

Marc

Not applicable
Author

Gysbert,

it works. By removing the " in the formula it worked. Thanks for the answer!!! It realy helped me out here.

Greetz,

Marc