8 Replies Latest reply: Mar 6, 2015 9:48 AM by Mukesh Chaudhari

Calculated Fields

Hi

I am creating a table where some of the fields I want are dependant on previously calulated fields, is there an easy way to do this

For example if I have calculated field [C] as follows,

[A] * [B] as [C] ,

then if I want field [E] to be [C] * [D] how can I do this without having to script [A] * [B] * [D]

Thanks

A.

• Re: Calculated Fields

Provide some sample data with your sample apps... will look into this..

• Re: Calculated Fields

[C] * [D] as [E] ;   // preceding load

[A] * [B] as [C]

From <>;

• Re: Calculated Fields

I've tried your method but it's not quite working.  I have a table which has a record for each sale and I'm trying to achieve a calculation of the distribution costs for each sale. So if my original tabel has 50 records, I should get a new table with 50 records, however I am getting 50 records for each sale.  This is the script and qvw attached

'CalcTest':

Load ((Pallets - DirectPallets) * DistributionCost) + (DirectPallets * DirectDistributionCost) as TotDistribution;

Year,
Week,
Product,
Units,
Pallets,
Pallets * DirectPallet% as DirectPallets,
DistributionCost,
DirectDistributionCost
resident 'Sheet1';

drop field DistributionCost,
DirectDistributionCost,
DirectPallet%;

• Re: Calculated Fields

If you want the other variables still to be visible, please add a '*,'

((Pallets - DirectPallets) * DistributionCost) + (DirectPallets * DirectDistributionCost) as TotDistribution;

• Re: Calculated Fields

If you want to calculate it in the same table, and you don't want to re-script the formula, then a preceding load may help you.

This looks like

Table X

c*d as Y;

a*b as C

FROM .....

Notice the ';' after the first load statement

• Re: Calculated Fields

Hi,

TableName:

*,

[C] * [D] AS E;

[A] * [B] as [C] ,

[D]

FROM DataSource;

Hope this helps you.

Regards,

Jagan.

• Re: Calculated Fields

Try this:

t1:

[

A,B,D

1,2,3 ]

;

t2:

A*B as c

resident t1

;

temp:

load c as C  resident t2;

join

;

final:

load C*D as E resident temp;

drop table t1,t2,temp

• Re: Calculated Fields

Hi,

U can achieve these through Preceding Load.

Regards,

Mukesh Chaudhari