Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

adrianbuzer
Contributor II

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 as follows,

Load

* as ,

then if I want field to be * how can I do this without having to script * *

Thanks

A.

1 Solution

Accepted Solutions
puttemans
Valued Contributor

Re: Calculated Fields

Hi Adrian,

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

Load  *,

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

8 Replies

Re: Calculated Fields

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

MVP
MVP

Re: Calculated Fields

Try preceding load like,

Load

* as ;   // preceding load

         

Load

* as

From <>;

puttemans
Valued Contributor

Re: Calculated Fields

Hi Adrian,

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

LOAD

c*d as Y;

LOAD

a*b as C

FROM .....

Notice the ';' after the first load statement

MVP
MVP

Re: Calculated Fields

Hi,

Try Preceding Load for this

TableName:

LOAD

*,

* AS E;

Load

* as ,

FROM DataSource;

Hope this helps you.

Regards,

Jagan.

Re: Calculated Fields

Try this:

t1:

load * Inline

[

A,B,D

1,2,3 ]

;

t2:

load

A*B as c

resident t1

;

temp:

load c as C  resident t2;

join

load D  resident t1;

;

final:

load C*D as E resident temp;

drop table t1,t2,temp

adrianbuzer
Contributor II

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;

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

drop field DistributionCost,
DirectDistributionCost,
DirectPallet%;

puttemans
Valued Contributor

Re: Calculated Fields

Hi Adrian,

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

Load  *,

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

mukesh24
Contributor III

Re: Calculated Fields

Hi,

U can achieve these through Preceding Load.

Regards,

Mukesh Chaudhari

Community Browser