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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
MEJ
Contributor III
Contributor III

Setting expression as variables

I would like to set all my common expressions as a reusable variable. 

I use variables for other purposes, but when I tried to set a variable "=sum(Revenue)", it didn't work as expected.

For some reason the calculation doesn't work with all dimension. It only shows the total revenue of the whole database, and enters the same value for all dimensions. The total value can be billions or trillions, depending on the number of dimensions I have in the Pivot table. Any simple solution for this?

Thanks

4 Replies
MEJ
Contributor III
Contributor III
Author

No one knows?

I've seen posts about this, but I haven't been able to replicate it, or at least it wasn't working for me.

Vegar
MVP
MVP

It can be a bit tricky with expressions and dollar expansions. Dollar expansions are often calculated "outside" the object and will give you the grand total of your selection even inside a multidimensional object.

I don't have the solution for this in the top of my head, but try to adjust the use of equal signs, apostrophes in expansion and in the variable expression.
Brett_Bleess
Former Employee
Former Employee

Have a look at the following Design Blog post, I think it might help you out here in addition to what the other poster already gave you!

https://community.qlik.com/t5/Qlik-Design-Blog/The-Magic-of-Variables/ba-p/1465499

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
rubenmarin

Hi, you need to remove the starting equal sign.

Starting with an equal the variable is evaluated globally and the result value is used, that's why every row is the same.