Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
jldengra
Creator
Creator

When does QV evaluate a variable value as a field and when as a text ?

In the QlikView Films sample, you can change the language by selecting it in a Multibox object, and all the texts are changed to the selected language.

For example, the third tab title is dynamic, defined as:

=Minstring(if(Reference = 'QV Guide', $(vLanguage)))

In the data model there are two disconnected tables:

Dictionary (Reference, EN, SE, FR, DE, NL, FI, IT, DK, JP, BG, NW)

Language (Language)

where the attribute Language is loaded with the values EN, SE, FR, DE, NL, FI, IT, DK, JP, BG, NW (column names of Dictionary table).

The variable vLanguage is defined at Document Properties / Variables as:

=Minstring(Language)

When a language is selected, let it be "DE", this tab is titled "Bedienung", since this is the value in the table Dictionary for the field DE when the Reference field value is "QV Guide".The vLanguage variable is set to "DE", and it is evaluated as the field DE returning its Minstring value, not the constant text "DE" that I was expecting.

Then QV is evaluating the value of the variable as a field name.

Do you understand why QV deals with it like that ?

When does QV evaluate a variable value as a field name and when as a text ?

Thank you in advance.

J.L. Dengra

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Please check the Help for dollar sign expansion:

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.

So your $(vLanguage) in your expression will be replaced with DE just before the expression is evaluated, like a text replacement. The expression evaluation will take DE as a field name, just as you put the literals there manually.

Hope this helps,

Stefan

View solution in original post

2 Replies
swuehl
MVP
MVP

Please check the Help for dollar sign expansion:

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.

So your $(vLanguage) in your expression will be replaced with DE just before the expression is evaluated, like a text replacement. The expression evaluation will take DE as a field name, just as you put the literals there manually.

Hope this helps,

Stefan

Miguel_Angel_Baeyens

Hi,

If the function you are using is expecting a field name (for example ApplyMap(), Sum(), Lookup(), etc) the variable will be expanded and its value used as a field name. Variables are quite plain in QlikView, they only store values: there are no arrays, associative values, as in other programming languages.

Say that you have a table Customer and a table Vendor with CustomerAmountDue and VendorAmountDue fields in each, the variable "vCompanyType" and for some reason, you need to use this variable to build the fieldname in a chart you use Sum() already:

SET vCompanyType = Vendor;

Sum($(vCompanyType)AmountDue))

Sum() will evaluate the content of the variable, if that fits into a field name Sum() will return the expected result, otherwise it will return a null value or a zero.

Hope that helps.

Miguel