Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
dthornburg
Contributor II
Contributor II

Merging Data in Load Script

Hi,

 

I have 2 tables of data. 1 contains transaction data and the other has how many hours were worked for a given date and shift. I want to get the number of hours for the day merged with the transaction data. The issue I have is the hours gets duplicated for every transaction. I get 8 hours for each record for the day/shift. I only want to load the first time I see a date/shift. How can this be accomplished?

 

dthornburg_0-1626204914229.png

 

1 Reply
Kushal_Chawda
MVP
MVP

@dthornburg  one way is like below

T1:
LOAD [Trans Date],
           Shift,
          [Wo Nbr],
           Qty
FROM TableA;

left join(T1)
LOAD [Trans Date],
            Shift,
            Hours
FROM TableB;

Final:
LOAD [Trans Date],
            Shift,
           [Wo Nbr],
          Qty,
          if(([Trans Date]=previous([Trans Date]) and Shift<>previous(Shift)) or
         [Trans Date]<>previous([Trans Date]),Hours,null()) as Hours
resident T1
order by [Trans Date],Shift,[Wo Nbr];

drop table T1;