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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
dmohanty
Partner - Specialist
Partner - Specialist

Expression in Variable, summing up when used in Chart

Hi Team,

Its a pretty simple thing, but am stuck somehow.

Created a variable called, V_Expression = Sum {<Set  Analysis>} (Sales)


Using the variable in a Straight Table, with a Single Dimension, let's say Product. I would expect it show as like this -


ProductSales
P1$200
P2$500
P3

$300

Where as its showing as -

ProductSales
P1$1,000
P2$1,000
P3$1,000

Please help on how to still use the expression in Variable and use the variable in Chart.

6 Replies
andrey_krylov
Specialist
Specialist

Hi Dicky, this variable should be a string and not a calculated value

V_Expression = 'Sum {<Set  Analysis>} (Sales)';

marcus_sommer

Your variable should contain:

Sum( {<Set  Analysis>} Sales)


and not:


= Sum( {<Set  Analysis>} Sales)


and then it should work.


- Marcus

dmohanty
Partner - Specialist
Partner - Specialist
Author

Hi andrey.krylov,

Thank you. but some how not helping though adding it as a string. Did I miss anything?

andrey_krylov
Specialist
Specialist

Hard to say but most  likely. What does it show now? And maybe some sample..

dmohanty
Partner - Specialist
Partner - Specialist
Author

Hi marcus_sommer

Thank you. this one helped.

But for some reason, I have to use the Sum ( ) again the expression part of the chart, like this = Sum (V_Expression).

Here its not allowing as a part of nested aggregation.

Can we use Aggr ( ) somehow in the expression part?

marcus_sommer

Yes, you will need an aggr() but if you could add them to the variable depends on your real expression. In this simplified case it should work:

V_Expression:

aggr(Sum( {<Set  Analysis>} Sales), Dim1, Dim2)


and then:


sum($(V_Expression))

If not you could do it in this way:

sum(aggr($(V_Expression), Dim1, Dim2))

- Marcus