BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
paul_apicella
Community Trekker

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

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

0 Kudos
2 REPLIES 2
ms
Super User ms
Super User

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

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][])

);


0 Kudos
paul_apicella
Community Trekker

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

Thanks MS, it works very well !

0 Kudos