- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
set a variable
hi,
i want to set a variable in the script that have-
if($(v_metric_5)<90,'red',if($(v_metric_5)<95,'yellow',if($(v_metric_5)<=100,'green','gray')))
how can i do that?
i dont want that $(v_metric_5) will calculate
i want it to stay as a string
adi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not sure, what do you mean by string? May be this
if('$(v_metric_5)'<90,'red',if('$(v_metric_5)'<95,'yellow',if('$(v_metric_5)'<=100,'green','gray')))
How you have created this variable v_metric_5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes what is that v_metric_5 ??
is it is a variable ?? if varible then it will take the values as per the variable value.
if it is field then you no need to consider it as string or any other format...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is the difference between setting the variables:
SET vVariable = 1 + 2; //Value returned 1 + 2
LET vVariable = 1 + 2; //Value returned 3
See the attachment that might be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dollar Sign Expansion (DSE) always occurs in script, which is generally a blessing but sometimes a curse. One workaround is to use a proxy character for the $ and then replace(). For example:
LET v1 = replace(
'if(@(v_metric_5)<90,''red'',if(@(v_metric_5)<95,''yellow'',if(@(v_metric_5)<=100,''green'',''gray'')))'
,'@','$');
You will need to double up your single quotes to allow them within the LET string.
Another approach is to use a proxy char for both $ and ' replacing both with a mapsubstring:
EscapeCharsMap:
MAPPING LOAD * INLINE [
from, to
@,$
|,'
];
LET v2 = MapSubString('EscapeCharsMap',
'if(@(v_metric_5)<90,|red|,if(@(v_metric_5)<95,|yellow|,if(@(v_metric_5)<=100,|green|,|gray|)))'
);
-Rob