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: 
kashjaniqlik
Contributor III
Contributor III

Using variables in Straight table

Hello

I have a variable to do a sum of a field in my data model. The result is then split by another field in the column

For e.g. Sum of total customers. This is then split by countries.

UK - 500

US - 300

Total - 800


If I use a straight table with Countries as dimension and =SUM(totalcustomers) as expression, this works all OK.

If I then use a variable to store the sum of total customers and use this variable as expression, the straight table doesn't seem to split by countries. It shows the total customers for all countries.

UK - 800

US - 800

Please see attached.

Thanks

1 Solution

Accepted Solutions
6 Replies
sunny_talwar

Have you used the '=' when defining your variable? Try '=Sum(totalcustomers)' vs 'Sum(totalcustomers)'

mphekin12
Specialist
Specialist

Can you post a sample of your app?

maxgro
MVP
MVP

try to read here

The Magic of Variables

kashjaniqlik
Contributor III
Contributor III
Author

Hi Sunny

Yes all variables are defined with an "=" sign.

SET vTotalCustomers = '=SUM(TotalCustomers)';

Thanks





kashjaniqlik
Contributor III
Contributor III
Author

Thanks Massimo‌

maxgro
MVP
MVP

try with one of

Set vTotalCustomers = Sum(TotalCustomers) ;

Let vTotalCustomers = 'Sum(TotalCustomers)' ;

and then as expression in chart

$(vTotalCustomers)