Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I would like to load some parameters into variables from a table "Parameters":Parameters
In the load script, I want to use the lookup function to store the value "Waarde" into the variable vKostIntern:
LET vKostIntern = Lookup('Waarde','Parameter','vKostIntern','Parameters');
I tried different things but the value of the variable remains empty.
Does anyone have a solution for this?
Hi, it should work, check again all the field and table tables, every is case-sensitive.
Also confirm that the table is already loaded in data model before the LET instruction.
Also note that you can create all variables from excel with a sfipt like:
Variables:
LOAD
Parameter,
Waarde
FROM ... excelFile;
FOR i = 0 to NoOfRows('Variables') - 1
LET vParameter = Peek('Parameter',$(i),'Variables');
LET $(vParameter) = Peek('Waarde',$(i),'Variables');
NEXT i
Maybe Waarde needs some number formatting with Num#() and/or Num() to correctly interpret the decimal separator.
Hi, it should work, check again all the field and table tables, every is case-sensitive.
Also confirm that the table is already loaded in data model before the LET instruction.
Also note that you can create all variables from excel with a sfipt like:
Variables:
LOAD
Parameter,
Waarde
FROM ... excelFile;
FOR i = 0 to NoOfRows('Variables') - 1
LET vParameter = Peek('Parameter',$(i),'Variables');
LET $(vParameter) = Peek('Waarde',$(i),'Variables');
NEXT i
Maybe Waarde needs some number formatting with Num#() and/or Num() to correctly interpret the decimal separator.
@Mark_A , I think you should use a peek function instead.
I don't know how long your table is but this loop should work and create the variables for you
the Trace functions are there as a testing thing. you can remove those 🙂
Parameters:
Load * inline [
Parameter, Waarde
vTest, 10
vTest2,100
];
let row = RowNo();
for Each vFields in FieldValueList('Parameter')
Trace - $(vFields)-;
let $(vFields) = peek('Waarde',$(row),'Parameters');
let row = $(row) + 1;
Trace - $(vFields)-;
next
Hi Ruben, thanks for the reply.
This code is certainly helpful.
I found where I made an error:
I use $(vKostIntern) in my expressions, which turns out to be Null.
When I replace this with vKostIntern, without $(), everything works fine.
Previously, the value of the variable was hard-coded:
LET vKostIntern = 0.425;
In this case both $(vKostIntern) and vKostIntern return the value.
The use of $() still keeps confusing me sometimes.