Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
mla3eruva
Contributor III
Contributor III

Creating a new table using existing resident tables

I need to create a new table in my model that unions two dimension tables.  In our fact table, we have two different attributes (Project# and an Award#) on each row - each of two attributes can be "owned" by the same or different organizations.  I can easily select all the Projects owned by an Org OR all the Awards owned by an Org.  I need a new field that allows me to select all the rows where an Org owns either/both of the Awards and Projects.

I'm new to Qlik and think I'm missing something pretty basic in how to create this bridge table but i can't figure out what the load script needs to be.

My starting data looks like this:

    

Fact Table
Project IDAward IDProject-Award KeyAmount
ABC123ABC-123100
DEF123DEF-123100
GHI345GHI-345100
JKL678JKL-678

100

  

Project Dim
Project IDProject Org
ABCSales
DEFMarketing
GHIFinance
JKL

Operations

  

Award Dim
Award IDAward Org
123Sales
123Sales
345Operations
678Finance

My new table should look like this:

  

Project-Award KeyOrg
ABC-123Sales
DEF-123Marketing
GHI-345Finance
JKL-678Operations
DEF-123Sales
GHI-345Operations
JKL-678Finance

I've attached a QVW with some sample data below.

Thank you in advance.

2 Replies
Gysbert_Wassenaar

Try this:

Fact:

LOAD * Inline [

Project_ID,Award_ID,Project_Award_Key,Amount

ABC,123,ABC-123,100

DEF,123,DEF-123,100

GHI,345,GHI-345,100

JKL,678,JKL-678,100

];

PA:

LOAD * Inline [

Project_ID,Project_Org

ABC,Sales

DEF,Marketing

GHI,Finance

JKL,Operations

];

AW:

LOAD * Inline [

Award_ID,Award_Org

123,Sales

123,Sales

345,Operations

678,Finance

];

mapPA:

mapping load * Resident PA;

mapAW:

mapping load * Resident AW;

Result:

LOAD distinct Project_Award_Key, applymap('mapPA',Project_ID) as Org Resident Fact;

Concatenate(Result)

LOAD Project_Award_Key, applymap('mapAW',Award_ID) as Org Resident Fact;


talk is cheap, supply exceeds demand
mla3eruva
Contributor III
Contributor III
Author

Thank you Gysbert

That does it - I'll try it my actual script with the full tables.

Mark