Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
chriys1337
Creator III
Creator III

Combining if condition and set a variable inside load table statement

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!

 

 

 

3 Replies
Or
MVP
MVP

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.

Saravanan_Desingh

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;
Kushal_Chawda

@chriys1337  what if you have more than one value for measure=1?