Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
jagan
Luminary Alumni
Luminary Alumni

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
Author

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

jagan
Luminary Alumni
Luminary Alumni

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
Author

I meant opening balance and sum