Subscribe Bookmark RSS Feed

Return the number of items in data row

Hegedus

Community Trekker

Joined:

Jun 23, 2011

Hi,

I have a data set where one of the columns is a list of entries such as  1,2  or 7,8,10,12 or blank  I would like to create a new column with the number of entities in each row.

I have tried

New column(

  "Num_Bumps",

  Numeric,

  Continuous,

  <<set each value(N Items(:Pad #))

)


Where Pad # is the column with entries.

This doesn't work because Pad # is not recognized as a list.

How should it be coded?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

You could use the WORDS function with a comma delimiter.

dt = New Table( "Example", Add Rows( 4 ), New Column( "Pad #", Character, Nominal,

        Set Values( {"1,2,3", "4,5,6", "", "1,2"} )

    ),

);

dt << New Column( "Num_Bumps", Numeric, Continuous, Format( "Best", 12 ),

        Formula( N Items( Words( :Pad #, "," ) ) ) );

2 REPLIES
Solution

You could use the WORDS function with a comma delimiter.

dt = New Table( "Example", Add Rows( 4 ), New Column( "Pad #", Character, Nominal,

        Set Values( {"1,2,3", "4,5,6", "", "1,2"} )

    ),

);

dt << New Column( "Num_Bumps", Numeric, Continuous, Format( "Best", 12 ),

        Formula( N Items( Words( :Pad #, "," ) ) ) );

Hegedus

Community Trekker

Joined:

Jun 23, 2011

Thank you.