Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using Load Resident on 2+ Tables

I am trying to pull fields out of two different tables to perform a calculation that will be a new field.  I am trying to do this with two load resident statements but cannot get the syntax to work.  I am hoping someone can correct my code or provide info for a better way to perform the same calculation.  From the table viewer everything is correctly joined, could there be an easier way to perform calculations to make new fields in script than load statements?  Thank you.

[Tap/Charge Tons]:

Load

    [Charge Tons],

   

Resident [TotalChargeMaterial];

Load

    [Tap Weight],

    ([Plant] & [Melt Number]) as %MeltNumberKey,

   

Resident [Melt Log];

[Tap Weight]/2000/[Charge Tons] as [Tap/Charge Tons] Group By %MeltNumberKey

//Not sure if Group By is needed or not to Join tables correctly

4 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi,

you're going to need at least one key between your two tables. Do you have Plant and Melt Number available in your TotalChargeMaterial table?

Marcus

rustyfishbones
Master II
Master II

Create the Calculations in a Preceding Load

Not applicable
Author

Yes, both tables have the %NektNumberKey

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Ok then, maybe something like this

_temp:

Load

([Plant] & [Melt Number]) as %MeltNumberKey

[Charge Tons]

Resident [TotalChargeMaterial];

LEFT JOIN (_temp)

Load

    [Tap Weight],

    ([Plant] & [Melt Number]) as %MeltNumberKey,

Resident [Melt Log];

FINAL:
NOCONCATENATE LOAD

%MeltNumberKey,

Sum([Charge Tons]) as [Charge Tons],

Sum([Tap Weight]) as [Tap Weight],

Sum( ([Tap Weight] / 2000) / [Charge Tons] ) as [Tap/Charge Tons]

RESIDENT _temp

Group By %MeltNumberKey;

DROP TABLE _temp;