Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Calculation between 2 tables

Hi, I need to sum up the fieldnames in red: Opening Balance and sum, but they are in different tables. How can I do it? Currently the table clbal contains all variables from bal and clbal tables. The words in blue are the common variables.

load*,date(timestamp#(Date, 'YYYYMMDDhhmm')) as DATE;

bal:

LOAD Date,

     storelocation AS StoreLocation,

     Opening_Balance as openingbal

FROM

(txt, codepage is 1252, embedded labels, delimiter is '|', msq);

clbal:

load *,if(peek(StoreLocation)=StoreLocation,peek(openingbal),0) as Closing_Balance,

    openingbal as Opening_Balance

    resident bal order by StoreLocation,Date desc;

load *,sqlDate as DATE,

sqlStoreLocation as StoreLocation,

Receipts+Returns+transfer_out+transfer_in+

issue_from_store+intmxmp+return_to_store+[total_receipts-returns]+stock_adjustments+

adjustments_to_current_balance+loan_transfer_out+loan_transfer_in as sum;

Thanks.

4 Replies
MVP
MVP

Re: Calculation between 2 tables

Hi,

Check this script

bal:

LOAD Date,

     storelocation AS StoreLocation,

     Opening_Balance as openingbal

FROM

(txt, codepage is 1252, embedded labels, delimiter is '|', msq);

clbal:

load *,if(peek(StoreLocation)=StoreLocation,peek(openingbal),0) as Closing_Balance,

    openingbal as Opening_Balance

    resident bal order by StoreLocation,Date desc;

DROP TABLE bal;

LEFT JOIN (clbal)

load *,

sqlDate as DATE,

sqlStoreLocation as StoreLocation,

Receipts+Returns+transfer_out+transfer_in+

issue_from_store+intmxmp+return_to_store+[total_receipts-returns]+stock_adjustments+

adjustments_to_current_balance+loan_transfer_out+loan_transfer_in as sum

FROM Table2;

Regards,

Jagan.

Not applicable

Re: Calculation between 2 tables

Thanks, so where do I put the script to sum up the variables?

MVP
MVP

Re: Calculation between 2 tables

Hi,

Is

Receipts, Returns,transfer_out, transfer_in, issue_from_store, intmxmp, return_to_store, [total_receipts-returns], stock_adjustments, adjustments_to_current_balance, loan_transfer_out, loan_transfer_in

are variables?

If yes then do like this

load *,

sqlDate as DATE,

sqlStoreLocation as StoreLocation,

$(Receipts)+$(Returns)+$(transfer_out)+$(transfer_in)+

$(issue_from_store)+$(intmxmp)+$(return_to_store)+$([total_receipts-returns])+$(stock_adjustments)+

$(adjustments_to_current_balance)+$(loan_transfer_out)+$(loan_transfer_in) as sum

FROM TableName;

Hope this helps you.

Regards,

Jagan.

Not applicable

Re: Calculation between 2 tables

I meant opening balance and sum

Community Browser