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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
lukegilligan
Contributor III
Contributor III

Remapping parent fields to child

I have a set of data that contains a "Parent" reference, that links back to the same table but a different record:

Customer:

LOAD

code,

name,

    oid AS myCustomer,

    isChildAccount,

    IF(myParent=0,'',myParent) AS myParent;

SQL SELECT

code,

name,

    oid,

    isChildAccount,

    myParent   

FROM LoginSchema.Customer;

LEFT JOIN (Customer)

LOAD

getCustomer AS myCustomer,

    getJCJob AS myJCJob,

    myAssociatedJob,

    myHousingCRMOrganisation,

    getCRMOrganisation,

    oid AS myHousingCustomer;   

SQL SELECT

getCustomer,

    getJCJob,

    myAssociatedJob,

    myHousingCRMOrganisation,

    getCRMOrganisation,

    oid

FROM LoginSchema.HousingCustomer;

I am wanting to populate everything from the parent record against the child record, but can't get my head around how to have the records loop back on themselves.

Any help would be much appreciated.

Thanks

1 Reply
petter
Partner - Champion III
Partner - Champion III

1. Solve it directly in QlikView or Qlik Sense by using the Hierarchy load prefix:

The syntax:

https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/ScriptPrefixes...‌‌

Excellent articles by Qlik's own master Henric Cronström:

Hierarchies

Unbalanced, n-level hierarchies

2. Alternatively solve it with the source database's own syntax in the SQL statement:

This is a such a common challenge so all the larger SQL database vendors have provided a special syntax to solve this. Here is the general information about the topic: Hierarchical and recursive queries in SQL - Wikipedia