Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
truppell
Contributor

Variable expansion, quotes and equal sign

Hi,

I have figured how to do what I want, but I don't completely understand how it is working. If there's anyone out there who understands this, I would love for you to explain it to me and let me know if there is any other way to accomplish the same result.

sample_table1:

LOAD * INLINE [

  location

  siteA

  siteB

  siteC

  siteD

];

SET vTest2= =Concat(location, ', ');

Then in my report I have a table with dimension of ='$(vTest2)'

Which give the result of siteA, siteB, siteC, siteD (or whichever of these are selected)

(I need it to be a table dimension because in my real app, I need to display it as a URL, and my understanding is that only table dimensions can be clickable URLs)

Why do I need the equal sign in the table dimension? This blog post (The Little Equals Sign) says that data can be interpreted as expression or text, and the default varies for different objects.

  • If the table dimension is looking for an expression, we do we need the equal sign? Why doesn't '$(vTest2)' work?
  • If the table dimension is looking for text, why do we need the equal sign and quotes? Shouldn't the equal sign in the variable itself be sufficient to trigger the calculation? Why doesn't $(vTest2) work?

Thanks,

Tanya

6 Replies
xufei123
Valued Contributor

Re: Variable expansion, quotes and equal sign

I have no idea about why. I've seen a lot of strange thing in Sense...

In the official help page, it just says so:

Creating a calculated dimension ‒ Qlik Sense

shraddha_g
Honored Contributor III

Re: Variable expansion, quotes and equal sign

What is the qliksense version you are using?

truppell
Contributor

Re: Variable expansion, quotes and equal sign

Version 2.2

Is the behaviour different in more recent versions?

truppell
Contributor

Re: Variable expansion, quotes and equal sign

Ok, so I'm making progress. I think I understand this much (there is a follow-up question below):

In the dimension definition: ='$(vTest2)'

  • The equal sign tells Qlik that it's an expression to be evaluation, not just text.
  • The single quotes tell Qlik to treat what's inside as a literal string, not a field name.

Then for the variable: SET vTest2= =Concat(location, ', ');

  • The scope of the equals sign does not carry into variables. Qlik assumes anything within $() is just text.
  • To get Qlik to evaluate the expression, we need to add the equal sign within the variable.

=====================================

FOLLOW-UP QUESTION

How can I make this work without any variable or dollar-sign expansion? I've tried defining my dimension as:

  • ='Concat(location, ', ')'
  • ='=Concat(location, ', ')'

But neither of those work.

I can do it without the variable by defining the dimension like this: ='$(=Concat(location, ', '))', but why do I need dollar-sign expansion if I have no variable?

Thanks!

Tanya

xufei123
Valued Contributor

Re: Variable expansion, quotes and equal sign

Maybe some Qlik expert can help you with "why" but as a first line developer, I will define a variable in the front (not script) like this:

and then use it to the dimension:

Fei

truppell
Contributor

Re: Variable expansion, quotes and equal sign

Oh - isn't that interesting! I thought I always needed dollar-sign expansion when using a variable. This syntax is so confusing!