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
hacketkm
Level III

Assign a value in a list to column values

By using a modal window, the user assigns a value (for example "ABC10") to a variable (my value) and I would like to fill a column with that value. My code looks like this:

my value = { "ABC10" };

dt << New Column( "My Column");

For Each Row( :My Column[] = my value);

I am having trouble because my value is a list and the expression does not fit available column types. Can anyone help me out?

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: Assign a value in a list to column values

Try this:

For Each Row( :My Column[] = my value[1]);

View solution in original post

3 REPLIES 3
pmroz
Super User

Re: Assign a value in a list to column values

Try this:

For Each Row( :My Column[] = my value[1]);

Jeff_Perkinson
Community Manager Community Manager

Re: Assign a value in a list to column values

It's easy to do this as you create the column with the Set Values() message, which takes a list as it's argument.

You can also use the Repeat() function to ensure that the list is repeated for all the rows in your data table.

dt =

New Table( "my table", add rows( 10 ) );

my value = {"ABC10"};


mycol = dt <<

New Column( "My Column",

  character,

  set values(

  Repeat( my value, N Row( dt ) )

  )

);

-Jeff
jorgeramosdealm
Level III

Re: Assign a value in a list to column values

You can also use this to create a table with the elements from a list.


a={1,2,3,4,5};


tmp=new table("test",add rows (nitems(a)),new column("list A",numeric,set each value(a[row()])));