Subscribe Bookmark RSS Feed

how to change column format several columns

KinKame

Community Trekker

Joined:

Nov 30, 2015

Hello

I have a table created thru summary feature.

I would like to using a for () loop (target column #3 to #9)

1) change format for fixed dec to Percent

2) add cell color

thank you

Lionel

5 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Here is some sample code that I think will give you guidance on how to change the formats and the cell colors

Names Default To Here( 1 );

dt = Current Data Table();

// Change the formats

For( i = 3, i <= 9, i++,

       Column( dt, i ) << Format( "Percent", 9, 2 )

);

// Set cell colors

For( rownum = 1, rownum <= N Rows( dt ), rownum++,

       If( Column( dt,3 )[RowNum] <= .5,

              Column( dt,3 ) << color cells( "Blue", RowNum ),

              Column( dt,3 ) << color cells( "Green", RowNum )

       )

);

Jim
KinKame

Community Trekker

Joined:

Nov 30, 2015

Hello Jim

ok just using the column property (table, column number) ...

the set color is cool. JMP allows data manipulation in a nice way ...

thank ou very much.

very instructive post

KinKame

Community Trekker

Joined:

Nov 30, 2015

Jim,

I was trying to get a double For to address all row (as in your example) and multiple columns ...

but no success. Any idea?

For(ii=4, ii<11, ii++,

       Column(summary_executive_RNG_alignment, orignal_columns0[ii])

            << Format("Percent", 10, 1 );

            << justify text("center");

            For( RowNum = 1, RowNum <= N Rows( summary_executive_RNG_alignment ), RowNum++,

                 If( 0 < Column( summary_executive_RNG_alignment, orignal_columns0[ii])[RowNum] <= 0.6,

                      Column( summary_executive_RNG_alignment, orignal_columns0[ii] ) << color cells( "RED", RowNum ),

                      If(0.6 < Column( summary_executive_RNG_alignment, ii ) <= 0.9,

                           Column( summary_executive_RNG_alignment, orignal_columns0[ii]) << color cells( "Blue", RowNum ),

                           Column( summary_executive_RNG_alignment, orignal_columns0[ii]) << color cells( "GREEN", RowNum )

                      )

            )

       )

);

txnelson

Super User

Joined:

Jun 22, 2012

There are issues with your code.  The code below works, assuming the logic you are specifying is want you want.  The only statement that is not a valid statement is the << Justify Text("center").  It is only valid when referring to a display window text box.  The other errors are just improper references:

For( ii = 4, ii < 6, ii++,

       Column( summary_executive_RNG_alignment, orignal_columns0[ii] ) << Format( "Percent", 10, 1 );

       //<<justify text( "center" );

       For( RowNum = 1, RowNum <= N Rows( summary_executive_RNG_alignment ), RowNum++,

              If( 0 < Column( summary_executive_RNG_alignment, orignal_columns0[ii] )[RowNum] <= 0.6,

                     Column( summary_executive_RNG_alignment, orignal_columns0[ii] ) << color cells( "RED", RowNum ),

                     If( 0.6 < Column( summary_executive_RNG_alignment, ii )[RowNum] <= 0.9,

                           Column( summary_executive_RNG_alignment, orignal_columns0[ii] ) << color cells( "Blue", RowNum ),

                           Column( summary_executive_RNG_alignment, orignal_columns0[ii] ) << color cells( "GREEN", RowNum )

                     )

              )

       );

);

Jim
KinKame

Community Trekker

Joined:

Nov 30, 2015

Thank you for your fast feedback.

will study the code you proposed :-)

best regards

Lionel