
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Strings in a string as a variable
Hi guys,
I have a question to define a variable. If I want to define X as a string of formula: Variable='AAA BB C', how should I write it in the script?
Shall I write "Variable='AAA BB C'" as X? It seems not correct...Anyone can help?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Set YourVariable='AAA BB C'


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let vString='AAA BB C'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to assign value Variable='AAA BB C' to variable X, you can write
SET X = Variable='AAA BB C';
in load script, or add new variable in Variable Overview and assign defenition Variable='AAA BB C'
(without equal sign)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
let MaVar = 'A given text string';
set X = '=MaVar';
MaVar is a string. X is a formula that is = to MaVar. If you change the content of MaVar, you will change X.
As you may see, I used either let (a string) or set (a formula)
Fabrice


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are numerous ways you can define your variable. Kindly refer to the QlikView Reference Manual or Help topics.
Search for "Variables" in these materials and you will find the different ways of creating it and other facts about it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks guys! what I want to do is to define this formula as a variable in load script, and then, use it in the layout for certain conditions, like the example below:
In load script:
load A, B, C, 'variables='total asset' or variables='net income'' as X;
in layout:
create a demension: if(X,1,0) =====> I want the result to be if(variables='total asset' or variables='net income',1,0)
I know they have syntax error, but just want you to understand what I want to do here...I want it this way since I only need to change the defintion of X in load script without changing the layout anymore. This will make the result dynamic.
Will this method work well? How to fix the syntax errors? or any other suggestions?
Thanks a lot!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, You can create a variable in the Load statement. I am assuming the total_asset & net_income are fields in the table then please try like below:
Let vVariable = 1000 ; //if the value is string you need to use single quotes
LOAD A, B , C , total_asset , net_income ,
IF(total_asset= $(vVariable) or net_incomce=$(vVariable) , 1, 0) AS Income_FLag //If the variable is string, use like '$(vVaribale)'
From source ;
Use directly Income_Flag as dimension in the chart

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, thanks for your reply! I think your answer is getting close to what I want, however the thing is that I would like to obtain <variables='total assets' or variables='net income'> as a string for X in load script, it's not to see if the two variables equal certain values...I'm not going to put the if condition here because I was creating a cross table(variables,value), so I cannot use 'variables' directly in the load script...
Not sure if I stated this issue clearly...
Thanks for your patience!
在 2014-1-27,22:29,"dathu.qv" <qcwebmaster@qlik.com> 写道:
QlikCommunity
Strings in a string as a variable
reply from dathu.qv in New to QlikView - View the full discussion
Hi, You can create a variable in the Load statement. I am assuming the total_asset & net_income are fields in the table then please try like below:
Let vVariable = 1000 ; //if the value is string you need to use single quotes
LOAD A, B , C , total_asset , net_income ,
IF(total_asset= $(vVariable) or net_incomce=$(vVariable) , 1, 0) AS Income_FLag //If the variable is string, use like '$(vVaribale)'
From source ;
Use directly Income_Flag as dimension in the chart
Reply to this message by replying to this email, or go to the message on QlikCommunity
Start a new discussion in New to QlikView by email or at QlikCommunity
Following Strings in a string as a variable in these streams: Inbox
© 1993-2014 QlikTech International AB Copyright & Trademarks | Privacy | Terms of Use | Software EULA
