Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I try to set a variable with a if condition when a field value (measure) is 1.
table:
Load
FieldA,
FieldB,
measure
FROM...
FieldA, Field B, measure
Porsche, Cayenne, null
VW, Golf, 1
Jeep, Renegade, null
if measure is 1, I would like to set a variable with value from Field B, so in my example I would like to set vVariable to Golf but I dont know how to set a variable inside the load statement combined with a if statement.
Any help is appreciated, thanks a lot!
I don't think you can do that directly from a load statement. You could loop through the values, but that's only feasible if the number of rows is on the small side. If you elaborate on what exactly you're trying to achieve, perhaps there's a workaround to be suggested.
Try something like this,
tab1:
LOAD * INLINE [
FieldA, Field B, measure
Porsche, Cayenne, null
VW, Golf, 1
Jeep, Renegade, null
];
FieldB1:
NoConcatenate
LOAD DISTINCT [Field B] As Var
Resident tab1
Where measure=1
;
LET vVariable=Peek('Var',0,'FieldB1');
Trace vVariable=$(vVariable);
Drop Table FieldB1;
@chriys1337 what if you have more than one value for measure=1?