Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Support Cases coming to Qlik Community Oct. 4! Start chats, open cases, explore resources: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

$ sign expansion - wtf?

Can somebody explain to me (or point me to a blog post), in simple terms, what the dollar sign expansion is? and how it can be used?. Ideally use a couple of practical examples as when I read the help or Designer II, it looses me with in the first sentence.

Thanks

Mark

9 Replies
swuehl
MVP
MVP

Mark,

I really don't know how to explain any better than the first sentences of the Help, which says:

Dollar-Sign Expansions

Dollar-sign expansions are definitions of text replacements used in the script or in expressions. This process is known as expansion - even if the new text is shorter. The replacement is made just before the script statement or the expression is evaluated. Technically it is a macro expansion.

A macro expansion always begins with '$(' and ends with ') ' and the content between brackets defines how the text replacement will be done. To avoid confusion with script macros we will henceforth refer to macro expansions as dollar-sign expansions.

You are probably not familiar with Macros? If you could tell me what exactely is hard to understand, I could try explaining that particular part.

I also find the examples in the Help quite understandable, so I am unsure how to simplify those examples.

Sorry for not being any big help,

Stefan

Not applicable
Author

Thanks for taking a moment to help me overcome my ignorance!

So taking the first sentence.... what is meant by "definitions of text replacements"?

Not applicable
Author

$ sign is commonly used in 2 ways:

A) as a operator to call the value of stored variable

B) In set analysis to use the current selection data

http://community.qlik.com/docs/DOC-1867

swuehl
MVP
MVP

The dollar sign expression itself is a definition, it tells QV what to do. QV should replace the dollar sign expansion, i.e. the part starting with $( and ending with ) with a text, and this before the actual evaluation of the "meaning" of the text in an expression takes place.

So

=$(vVariable)

will replace $(vVariable) with the content of the variable. Lets say we have defined the variable in variable overview like

sum(Value)

, then this text will replace the dollar sign expansion:

=sum(Value)

Then this will be evaluated, if used in an expression.

Not applicable
Author

link does not work.

michael_gardner
Creator III
Creator III

You can evaluate a variable in a expression that sometime wouldn't work normally.

Image 3.png

Not applicable
Author

So this is the difference -

='TWTFL without $'

='T$(WTF)L with $'


$(XXX) merely indicates that XXX is a variable, not text and its value must be substituted ?


michael_gardner
Creator III
Creator III

My example is just one use case.  See "www.naturalsynergies.com/q-tip-6-those-tricky-sign-expansions/" for a really good explanation and examples of uses.

Not applicable
Author

Thanks, in the second line of code in that link it says -

         // In this example, the chart expression is calculated dynamically, based on the value of the variable
         SET var2 = ‘sum(Sales)’;
         Chart Expression:                $(var2) 
Where do I set all these things ? Inside bar chart or elsewhere ?
Okay, I figured it out -
In variables overview, var2 = sum(SalesAmount)
Then, use var2 in chart as =($var2)
which brings me to my next question - Qlikview simple variable gives unexpected results in bar chart