8 Replies Latest reply: Feb 12, 2018 8:11 AM by Lukas Roček

# 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]

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...

• ###### Re: Variable in variable

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

• ###### Re: Variable in variable

Now I try this code: '[flag' & text(\$(vHour)) & 'hours] ={'1'}' , but I have a problem with apostrofs in braces

Any ideas?

• ###### Re: Variable in variable

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

• ###### Re: Variable in variable

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 ...

• ###### Re: Variable in variable

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

• ###### Re: Variable in variable

share some sample data

• ###### Re: Variable in variable

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.

• ###### Re: Variable in variable

Hi, I solved it.

As variable:

vVariale: text('avg({\$<[flag' & text(\$(vHour)) & 'hours]={''1''}>} flagEPA)')

measure: ...\$(=\$(vVariable)) ...