Qlik Community

Qlik Design Blog

All about product and Qlik solutions: scripting, data modeling, visual design, extensions, best practices, etc.

The Little Equals Sign

In QlikView, as well as in Qlik Sense, there are numerous places where you can enter texts or expressions: In text objects, as measures in charts, as labels of objects, in variables, etc. If you start the text with an equals sign, this tells QlikView that “here comes a formula”. So, QlikView evaluates the string and calculates the expression instead of just treating it as a text constant.

Sometimes you must to use an equals sign, and sometimes not. But how can you know whether you must use an equals sign or not?

Basically, QlikView can interpret the text in two ways; either as a text (i.e. as a value) or as an expression. And what QlikView does by default varies from place to place.

In a chart measure (the expression), the text is interpreted as an expression. This means that you do not need an initial equals sign. It is OK to enter one anyway – it will not change the interpretation. This is an assignment by expression. This means that the value will be recalculated every time the user clicks. If you instead want to show the text as text, and not evaluate it, you need to enclose it in single quotes. There are many places in QlikView that behave this way: Measures, background colors, show conditions, calculation conditions, etc.

Image4.png

This is very different from e.g. QlikView Text boxes. Here, the text is interpreted as text. This is an assignment by value. This means that if you write an expression, it will not be evaluated unless it starts with an equals sign. Many places in QlikView behave this way: Text boxes, labels, Set statements, dollar expansions, etc. All places where it makes sense to use a plain text or a simple value behave this way.

Image6.png

Variables need a couple of extra words. Normally, you assign a variable by value; either in the script using a Set or Let statement, or in the user interface through an Input box or in document properties (Variables sheet).

Image7.png

An alternative is to use an assignment by expression. Then the value of the variable will be recalculated every time the user clicks, before it is used in other formulas. Just make sure that the little equals sign is there, and it will work.

Image8.png

Dollar expansions use exactly the same logic. If you have a dollar expansion without an equals sign, the enclosed text will be read as-is and used as a variable name. But if you instead use an equals sign, the enclosed text will be evaluated before it is expanded.

For example, assume that the variable vEndYear has the value of ‘2014’. Then

     $(vEndYear) will be expanded as ‘2014’

whereas

     $(=vEndYear-1) will be expanded as ‘2013’

Finally, a small word of warning: The initial equals sign means an extra calculation every time the user clicks. And every small calculation uses some CPU time and carries a small performance penalty. Hence, you should not use too many calculated expressions. Use them only in the cases where you really need them.

The little equals sign is your friend. Use it wisely.

HIC

Further reading related to this topic:

The Magic of Variables

The Magic of Dollar Expansions

16 Comments
Marcio_Campestrini
Valued Contributor

Hi Henric

Thanks for sharing!

0 Likes
1,913 Views
Not applicable

Thanks Henric,

$(=vEndYear-1) Just sorted my issue out. 

Thanks

0 Likes
1,913 Views
borisman
Contributor III

Henric nailed it again - equal sign behaving differently in different places was one of the things that frustrated me the most when I started my journey with QlikView.

1,913 Views
Not applicable

I just started with QV and I was wandering why sometimes i needed equal and others dont. Thanks for clarifying it completly.

0 Likes
1,913 Views
Partner
Partner

Hi Henric

Thanks for your post.

0 Likes
1,913 Views
bestofwest
Contributor II

One of the things I don't like in Qlik View.

Good post.

0 Likes
1,913 Views
Luminary
Luminary

I'm still wondering why I can use $(vMaxYear) in an expression title without equal sign, but I have to use equal sign in a chart title or caption 😕

0 Likes
1,913 Views
bestofwest
Contributor II

Simple,

Because on chart title or caption the = is the first character.

You can use $(xxxx) as a title.  Is different of =$(xxx)

0 Likes
1,913 Views
Luminary
Luminary

Antonio Caria: what I ment is that in expression label you can simply write "Actual $(vMaxYear)" without equal sign and the variable is evaluated. But doing exactly the same in chart title or caption does not work. In chart title - as you write - I have to write "='Actual $(vMaxYear)' ".

0 Likes
1,913 Views
bestofwest
Contributor II

Correct.

In caption's (titles included) the behavior is different from expression.




0 Likes
1,913 Views

@ Juraj Mišina

You are right that there is an additional difference between different controls, and that is how they treat a dollar expansion. There are in fact three different control types:

Three control types.png

I'm not sure I like this behaviour either, but that is how it currently works.

HIC

0 Likes
1,913 Views
Luminary
Luminary

Thank you Henric for clarifying this. After a short time I've got used to it, but every now and then when creating chart captions/titles it comes to my mind...

0 Likes
1,913 Views
mayankraoka
Valued Contributor

Thank you Henric for clarification.....

0 Likes
1,913 Views
Partner
Partner

Pardon me if it is too simply that I was unable to catch.

In QlikView, we have Dynamic Expression labels which I am unable to use in Qlik Sense.

For eg. "=ClientName" works fine in QlikView and shows the respective Client where as Qlik Sense is directly showing the text "=ClientName" rather than the value of ClientName variable.

Note: Double quotes are only to highlight the variable name. Double quotes are not used in the dashboard.

Cheers,

Naresh

0 Likes
1,913 Views
Partner
Partner

Anyone came across this kind of requirement?

0 Likes
1,913 Views
qlik4asif
Contributor II

now i am clear about equal sign, Thanks!!!!!!!!!

0 Likes
1,913 Views