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

Variable in Chart Expression showing chart total instead of dimension total

I have created a variable to return the total number of opted in profiles, but when i use this variable in a chart, it's returning the total for the chart as the result for each dimension.  When i put the same expression directly into the chart expression, it works fine, but when i use the variable, it doesn't.  Can anyone tell me what i'm missing?

Here is the expression, i'm counting distinct profile IDs where they have an Opt In Flag = 1 but NOT Opt In Rem = 1 or OptOut Flag = 1:

=Count(DISTINCT {<OptIn_Flag = {1}, ProfileID = e( {<OptInRem_Flag = {1}>} ProfileID), ProfileID = e( {<OptOut_Flag = {1}>} ProfileID)>} ProfileID)

Opt In Variable.png

1 Solution

Accepted Solutions
jeevays7
Partner - Creator III
Partner - Creator III

Hi,

try this.

copy and paste below expression in a variable (without "=" infront of the expression.)

Count(DISTINCT {$<OptIn_Flag = {1}, OptInRem_Flag -= {1}, OptOut_Flag -= {1}>} ProfileID)


then in chart expression write this.


=$(variablename) (i.e variabel name is your variable name)

View solution in original post

5 Replies
sunny_talwar

Remove the '=' sign in front of your variable definition and see if that helps?

The Little Equals Sign

CarlosAMonroy
Creator III
Creator III

Hi Ashley,

You have the = sign in your variable definition. You have to remove it and the variable will work fine.

Thanks,

Carlos M

jeevays7
Partner - Creator III
Partner - Creator III

Hi,

try this.

copy and paste below expression in a variable (without "=" infront of the expression.)

Count(DISTINCT {$<OptIn_Flag = {1}, OptInRem_Flag -= {1}, OptOut_Flag -= {1}>} ProfileID)


then in chart expression write this.


=$(variablename) (i.e variabel name is your variable name)

Not applicable
Author

Marking this one as complete because it includes the extra step to add the dollar sign expansion to the variable name in the expression.  However, changing the syntax of the set analysis was not necessary - it still works the way I had it as long as i removed the = from the beginning.

jeevays7
Partner - Creator III
Partner - Creator III

Yes,

your expression also correct. the main thing is "=" only.