Using If statement while creating a tableHello all,
I am trying to create a table with an If () to set values to the cells. As shown in the piece of representative code below, I am using a variable, Counter, to point to a row in a separate summary table (dt) and use that as the values for the new table. However, I want to make sure that the code does not break if Counter=0, i.e. if the summary table where I am pulling the data from, does not contain the rows I want. I have used the method below but it doesn't work. I have tried placing the If () in various locations and haven't been successful either. Please suggest some ways if anyone has faced this issue before.
Thanks
D
New Column( "Parameters",
Numeric,
"Continuous",
Set Values( If(Counter>0,{dt:Col1[Counter], dt:Col2[Counter], dt:Col3[Counter]}, {N/A, N/A, N/A})
)
)
Data TableScriptingRe: Using If statement while creating a tableThe list values are not going to be processed. Therefore, the following will get done what I think you are trying to do.
names default to here(1);
dt=current data table();
counter=1;
theList = {};
if(counter>0,
insert into(theList, char(dt:col3[counter]));
insert into(theList, char(dt:col2[counter]));
insert into(theList, char(dt:col1[counter])),
theList = {"N/A", "N/A", "N/A"};
);
dtx=new table("test",
new column("Parameters", character,set values(eval(theList)))
);