Subscribe Bookmark RSS Feed

how to apply the same formula to several columns in a table?

paul_apicella

Community Trekker

Joined:

Feb 11, 2015

Hi,

I want to change the values contained in several columns of a database by applying a formula (see the attached example): values in "column a" must be modified according to  the formula (a - m1) / m2. Same procedure for "column b" ((b - m1) / m2) and similarly for each column.


Thanks in advance for any advice

2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

If you want to change the values in-place, i.e. overwrite the old values, the easiest way is to run a script.

dt = Data Table("test-table");

cols = dt << get column names;

For(q = 3, q <= N Items(cols), q++,

    For Each Row(cols[q][] = (cols[q][] - cols[1][]) / cols[2][])

);


paul_apicella

Community Trekker

Joined:

Feb 11, 2015

Thanks MS, it works very well !