BookmarkSubscribe
Choose Language Hide Translation Bar
Highlighted

How do I compare column values in loop using indexed naming.

I am trying to create a column and assign that column a value to a column only when the values in two other columns are equivalent.   I have to use indexed naming as I am in a loop and will not always know what the column name is or what the number is (see image below).  The script creates the new column but does not correctly evaluate my formula.    Please help! My Script:

dt<< New Column(RamanPeakList[NameIndex] || " Peak", <<Set Each Value(
If( Column(RamanPeakList[NameIndex] || " Peak Intensity") == Column("Temp"||RamanPeakList[NameIndex]),
:Raman Shift)));
1 ACCEPTED SOLUTION

Accepted Solutions

Re: How do I compare column values in loop using indexed naming.

If you were using a formula to set the values, then you code would probably work.  However, since you are using Set Each Value, I assume that you need to specify the specific row value to do the calculation on.  The below script worked for me

dt << New Column( RamanPeakList[NameIndex] || " Peak",
<<Set Each Value(
If(
Column( RamanPeakList[NameIndex] || " Peak Intensity" )[Row()] == Column(
"Temp" || RamanPeakList[NameIndex]
)[Row()],
:Raman Shift
)
)
);
Jim

Re: How do I compare column values in loop using indexed naming.

If you were using a formula to set the values, then you code would probably work.  However, since you are using Set Each Value, I assume that you need to specify the specific row value to do the calculation on.  The below script worked for me

dt << New Column( RamanPeakList[NameIndex] || " Peak",
<<Set Each Value(
If(
Column( RamanPeakList[NameIndex] || " Peak Intensity" )[Row()] == Column(
"Temp" || RamanPeakList[NameIndex]
)[Row()],
:Raman Shift
)
)
);
Jim