cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
lpatton
Level I

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!

 

 

 

RamanFail.png

 

 

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
txnelson
Super User

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

View solution in original post

1 REPLY 1
txnelson
Super User

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