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

Loops in joing tables

Good day!

in lscript i'm trying to load tables:

WorkingDays:

LOAD

Work_schedule,

    Дата,

    Status

FROM

$(DataPath)WorkingDays.xls

(biff, embedded labels, table is [WDays$])

where Дата < today(1);

WorkingShedule:

LOAD

  Distributor_Id,

  Work_schedule

  FROM

$(DataPath)WorkShedule.xls

(biff, embedded labels, table is [WShedule$]);

Also i have link_ table, which have key fields:

Дата,

Distributor_Id

When i do reload model, i see message with error:

Structure of model:

How i can make join between tables WorkingShedule, WorkingDays, Link_table without having loops in database structure?

Source files of tables WorkingShedule, WorkingDays are in attached files

Thanks.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Maybe all you need is to join WorkingDays and WorkingSchedule into one table.

There will be another issue, synthetic key, because this new table and Link Table have two fields in common - Distributor ID and Data.  But this is easy to resolve.  For example, create combined key field out of these two fields, and drop Distributor ID and Data from the Link table.

View solution in original post

18 Replies
Anonymous
Not applicable
Author

try dropping WorkingShedule table at the end of your script.

Anonymous
Not applicable
Author

ok. and where i will see data from table WorkingShedule after reload ?

sunny_talwar

If WorkingSchedule have only the two fields: Distributors_Id and Work_schedule then these two are also present in WorkingDays and Link_Table, respectively. But in case you have more than those two fields within WorkingSchedule, I would just rename one of the two fields so that it doesn't create a loop (for example Distributors_Id as WSDistributor_Id). This would break your direct link between WorkingSchedule and Link_Table, but your indirect link will stay intact breaking the loop.


Hopefully this would be helpful.


Best,

S

Anonymous
Not applicable
Author

thanks, but i can not rename any fields in Work_schedule, because Work_shedule is key field with WorkingDays table and Distributor_Id  field also used in others tables

sunny_talwar

Right, but the reason you are seeing the loop is because you WorkingShedule is connected to WorkingDays which is connected to Link_table which is again connected to WorkingShedule. Now the only way to break the loop is to break the link between one of those tables. (All the fields still exists, just one of them have to renamed.

Will you be able to share a qvw file for demonstration purpose?

Best,

S

Anonymous
Not applicable
Author

Thanks, but have not enough rights to share model... Sorry.((

Not applicable
Author

Hey there,

Can you pls explain how the Link table is created? Maybe that needs to be revisited. Also a sample qvw would help in debugging.

jschrader
Contributor III
Contributor III

Based on the information you have provided, the only way you could have created the link table was to match distribution_id and aata with work_schedule (I need more information if this is not the case). If this is the case, then you join your tables on work_schedule, then you should accomplish the same result while removing the loop. Creating a mapping load with distribution_id and work_schedule would also work.

Anonymous
Not applicable
Author

Maybe all you need is to join WorkingDays and WorkingSchedule into one table.

There will be another issue, synthetic key, because this new table and Link Table have two fields in common - Distributor ID and Data.  But this is easy to resolve.  For example, create combined key field out of these two fields, and drop Distributor ID and Data from the Link table.