Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis and Variables

Hi, 

Im using the following variable vSubSite :

if([Site]='North Division','Sub Site 1',

if([Site]='Central Division','Sub Site 2',

if([Site]='South Division','Sub Site 3',)))


which works (I'm testing this in a Text Box).


I have a chart with the following set analysis :


=sum({ <sub_site = {'Sub Site 1'}>} Number)

which plots perfectly.

If I try and use vSubSite1 : =sum({ <sub_site = {$(vSubSite1)}>} Number)   the chart fails to plot.

Is there something I'm doing wrong?

Many thanks for your time.

Tom

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Put an = in front of the expressions in the variables and surround the variable expansions with single quotes. See attached qvw.


talk is cheap, supply exceeds demand

View solution in original post

18 Replies
Not applicable
Author

Hi,

It is due to the space contained in your variable content, which is = Sub Site 1

Insert the variable name between brackets [], sth like {[$(vsubsite1)]}

See the doc I have written: http://community.qlik.com/docs/DOC-4951

Fabrice

sivarajs
Specialist II
Specialist II

Try this

sum({ <sub_site = {$(=vSubSite1)}>} Number) 

or

sum({ <sub_site = {=$(=vSubSite1)}>} Number) 

israrkhan
Specialist II
Specialist II

what is value is vSubSite1 in right side.

you are assigning to same variable, that using right side in set..

try like below in variable expression,

vSubSite1 =sum({ <sub_site = {$(vSubSite1)}>} Number)


if vSubSite1 in null, then it will not show any value...


and use this in text box

sum({ <sub_site = {$(vSubSite1)}>} Number)


Clever_Anjos
Employee
Employee

sum({ <sub_site = {"=$(=vSubSite1)"}>} Number) 

should work

Not applicable
Author

Hi Fabrice!

Thanks for your reply.  This works if I hard code the variable vsubsite1 = Sub Site 1

If I try and use the expression

vsubsite1 =

if([Site]='North Division','Sub Site 1',

if([Site]='Central Division','Sub Site 2',

if([Site]='South Division','Sub Site 3',)))

then the chart doesn't plot.

Any ideas?

Tom

Not applicable
Author

put the variable name between ' '

Cheers

Juan Pedro

Not applicable
Author

Hi,

Thanks, but none of these solutions seem to work.

Cheers,

Tom

Not applicable
Author

Hi, thanks but this solution doesn't work either (ive tried both  " and ' )

Thanks,

Tom

Not applicable
Author

Tom,

vEssai is a variable

= if(TIME_Key < 15, 'GAMME GOURMANDE')

 

As you see, there is a test (with if statement based on TIME that is chosen in a box), and the value is GAMME GOURMANDE (with a space)

sum ({<CONTENANT_LName = {[$(vEssai)]} > } [Ventes Valeur])

where

[Ventes valeur] is my variable

CONTENANT_LName my diimension

vEssai is enclosed into brackets []

Answer7.JPG

So it should work.

Perhaps, it does not work in your graph because there are several Site, and the formula does not return anything

Fabrice