Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
gerhardl
Creator II
Creator II

loop in data tables

Hi,

I have an Account_Table and it has an [Appl No].

I have and App_Table which also has an [Appl No], and a field called [Origin Code], with e.g. Origin 1 and Origin 2.

Not all the records from the Account_Table exist in the App_Table. These are migrated accounts (I can identify them this way in the Account_Table).

I want to give all the records that DO NOT exist in the App_Table an [Origin Code] of Origin 3.

For other reasons I have to load my Account_Table first, and then my App_Table.

What would be the best way to do this? I tried adding the [Origin Code] field to the Account_Table and saying if the account is migrated the [Origin Code] should be Origin 3, but then I create a loop.

Regards,

Gerhard

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Gerhard

I am a little confused. Where do you want to put the Origin 3 values if the record does not exist in the App Table? If you meant that you will create it in the Account Table, then make sure it is removed from the App Table.

This is what I would try:

MapOrigin:

Mapping LOAD [Appl No],

     [Origin Code]

FROM App_Table;

AccountTable:

LOAD [Appl No],

     ApplyMap('MapOrigin', [Appl No], 'Origin 3') As [Origin Code],

     ....

FROM Account_Table;

Now load App Table, but do not load Origin Code.

Does this do what you require?

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

2 Replies
datanibbler
Champion
Champion

Hi Gerhard,

well, you have to load the Account_table first and then the App_table, and then you want to single out all the records - from the Account_table, I reckon - that do not exist in the App_table?

Right?`

Well, if you have both tables already loaded, that's easy: Just do a RESIDENT LOAD from the Account_table with a WHERE NOT EXISTS() clause referring to the ID in the App_table.

HTH

Best regards,

DataNibbler

jonathandienst
Partner - Champion III
Partner - Champion III

Gerhard

I am a little confused. Where do you want to put the Origin 3 values if the record does not exist in the App Table? If you meant that you will create it in the Account Table, then make sure it is removed from the App Table.

This is what I would try:

MapOrigin:

Mapping LOAD [Appl No],

     [Origin Code]

FROM App_Table;

AccountTable:

LOAD [Appl No],

     ApplyMap('MapOrigin', [Appl No], 'Origin 3') As [Origin Code],

     ....

FROM Account_Table;

Now load App Table, but do not load Origin Code.

Does this do what you require?

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein