
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Variable in variable
Hello,
I have a problem with using variable in another variable.
I use number slider from 1 to 6 (step by 1), which changing variable 'vHour' - so it is number.
Then I have the second (text) variable 'vPeriod', which is name of flag in load script.
I use set analyse with this flag, so I need change set analyse by text variable.
This code does not work: [flag&text($(vHour))&hours]
Load script for flags:
if(now()-num(eventdtcr) < 0.25,'1','0') as flag6hours,
if(now()-num(eventdtcr) < 0.2083,'1','0') as flag5hours,
if(now()-num(eventdtcr) < 0.1666,'1','0') as flag4hours,
if(now()-num(eventdtcr) < 0.125,'1','0') as flag3hours,
if(now()-num(eventdtcr) < 0.0833,'1','0') as flag2hours,
if(now()-num(eventdtcr) < 0.0416,'1','0') as flag1hours...
Set analyse: if(len(text(avg({$<$(vPeriod)={'1'}>} flagEPA))) = 0,'NO EVENT SCAN',avg({$<$(vPeriod)={'1'}>} flagEPA))
Next idea: '[flag' & text($(vHour)) & 'hours]' does not work too...
Thank you for your's answers.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I solved it.
As variable:
vVariale: text('avg({$<[flag' & text($(vHour)) & 'hours]={''1''}>} flagEPA)')
measure: ...$(=$(vVariable)) ...


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think by using this: '[flag' & text($(vHour)) & 'hours]' the following call should work:
if(len(text(avg({$<$(=vPeriod)={'1'}>} flagEPA))) = 0,'NO EVENT SCAN',avg({$<$(=vPeriod)={'1'}>} flagEPA))
Whereby I would probably use only one flag like:
hour(now()-eventdtcr) -1 as Flag
and as expression something like this:
alt(avg({$<Flag={$(vHour)}>} flagEPA), 'NO EVENT SCAN')
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your code does not work...
Now I try this code: '[flag' & text($(vHour)) & 'hours] ={'1'}' , but I have a problem with apostrofs in braces
Any ideas?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
share some sample data


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you mean you don't want just create the field for the set analysis else the complete set analysis statement? Then of course you would need to handle multiple quotings and here probably by doubling the quotes like ...{''1''} ... But I would use string-values in such cases else really using the pure number like ... {1} ... and of course creating the flags in this way too.
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah, I changed it by if(len(text(avg({$<$(vPeriod)>} flagEPA))) = 0,'NO EVENT SCAN',avg({$<$(vPeriod)>} flagEPA))
and vPeriod = 'flag' & text($(vHour)) & 'hours={''1''}'
but still does not work ...


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your variable needs to be evaluated before it's result is applied as set analysis statement with a $-sign expansion like above already mentioned - this meant: $(=vPeriod)
- Marcus


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Instead of making 6 flag columns, why not a single flagHour that contains 1 - 6 then you are changing the right side (as opposed to left) of the equation.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I solved it.
As variable:
vVariale: text('avg({$<[flag' & text($(vHour)) & 'hours]={''1''}>} flagEPA)')
measure: ...$(=$(vVariable)) ...
