Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Based on variable

Hello all,

I have a table where the the columns are actual and budget figures, where the names of the budget columns are that of the actuals but with the prefix 'B'. I try to create a variable based on that of another but I can't reference the contents correctly. This example should show the problem where the value of 'BValue' is 'BColA' rather than 101,124,121,105 I am trying to achieve:

test1:
LOAD * INLINE [
ColA, ColB, ColC, BColA, BColB, BColC
12, 15, 18, 101, 108, 114
25, 20, 17, 124, 122, 106
1, 29, 5, 121, 120, 117
6, 7, 11, 105, 108, 107
];

set vCol = 'ColA';
set vBCol = 'B' & '$(vCol)';
test2:
load recno() as recno,
$(vCol) as value,
$(vBCol) as BValue
resident test1;

Any thoughts?

Regards,

Gordon

1 Solution

Accepted Solutions
danielrozental
Master II
Master II

I believe you should use let instead of set for it to work.

let vCol = 'ColA';

let vBCol = 'B' & '$(vCol)';

View solution in original post

3 Replies
danielrozental
Master II
Master II

I believe you should use let instead of set for it to work.

let vCol = 'ColA';

let vBCol = 'B' & '$(vCol)';

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Actually, Set is what we typically use for storing expressions that will be evaluated later...

I'm puzzled - in my mind, your syntax should work... I got the expected result with the following:


set vCol = 'ColA';
set vBCol = B$(vCol);

I also got the expected result using LET:

let vCol = 'ColA';
let vBCol = 'B' & '$(vCol)';

I still can't explain why this one works, and the other one doesn't...

Oleg

Not applicable
Author

Thanks Daniel and Oleg,

The solution is in using LET instead of SET. LET evaluates so technically the statements should be:

set vCol = 'ColA';
let vBCol = 'B' & '$(vCol)';

Regards,

Gordon