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: 
Not applicable

join of tables to create a

Hello Community,


i would like to join two tables to achive the result as shown in: Joint Table.
I am using two xlsx inputs to get the data.


Right now I'm using a simple join, and the result is, that I get a table like the Joint Table BUT for all of the companies which don't have a group assigned in Input Table Group table, i get back a "-" -> means the company group field isn't filled.

How to a setup a join to have the following result:
If a company group is assigned to the company it should set be included in the company group field.
If no company group is assigned to the company in the lookup table, it should use instead of an assigned company group the company na


Thanks,
Mathias

Joint   Table
CompanyRevenueCompany Group
T-Mobile US 25,00 € T-Mobile Group
T-Mobile DE 52,00 € T-Mobile Group
T-Mobile UK 88,00 € T-Mobile Group
Vodafone DE 65,00 € Vodafone Group
Vodafone Spain 21,00 € Vodafone Group
Vodafone Italy 256,00 € Vodafone Group
O2 Germany 85,00 € O2 Germany
Eplus Germany 21,00 € Eplus Germany
Mobitel Italy 55,00 € Mobitel Italy

The input tables are:

Input   Table Group
CompanyCompany Group
T-Mobile UST-Mobile Group
T-Mobile DET-Mobile Group
T-Mobile UKT-Mobile Group
Vodafone DEVodafone Group
Vodafone SpainVodafone Group
Vodafone ItalyVodafone Group

AND:

Input Table Revenue
CompanyRevenue
T-Mobile US 25,00 €
T-Mobile DE 52,00 €
T-Mobile UK 88,00 €
Vodafone DE 65,00 €
Vodafone Spain 21,00 €
Vodafone Italy 256,00 €
O2 Germany 85,00 €
Eplus Germany 21,00 €
Mobitel Italy 55,00 €
1 Solution

Accepted Solutions
sbaldwin
Partner - Creator III
Partner - Creator III

had a further throught you could use a mapping load:

group_map:
mapping LOAD Company,
     [Company Group]
FROM
Book1.xls
(biff, embedded labels, table is Sheet2$);


main:
LOAD Company,
     Revenue,
     applymap('group_map',Company,Company) as [Company Group]
FROM
Book1.xls
(biff, embedded labels, table is Sheet1$);

Both have the same affect

Thanks

Steve

View solution in original post

4 Replies
sbaldwin
Partner - Creator III
Partner - Creator III

Hi once you have joined the table you could join the table back on itself using an isnull condition on the Group to create the final Company Group, something like :

main:
LOAD Company,
     Revenue
FROM
Book1.xls
(biff, embedded labels, table is Sheet1$);

Join (main)
LOAD Company,
     [Company Group] as temp_co
FROM
Book1.xls
(biff, embedded labels, table is Sheet2$);

Join (main)
load Company,Revenue,if( isnull(temp_co) ,Company,temp_co) as [Company Group]
resident main;


drop field temp_co;

Miguel_Angel_Baeyens

Hi,

I'd use a mapping table if there is a unique value for each Company, although a JOIN would work as well using the Company field as key field.

RevenueTableMap:

MAPPING LOAD Company,

     Revenue

FROM InputTableRevenue;

JointTable:

LOAD Company,

     ApplyMap('RevenueTableMap', Company, 'Not found') AS Revenue,

     "Company Group"

FROM InputTableGroup;

In its three parameter form, the ApplyMap() function takes the mapping table single quoted as the first parameter, the field which correspondence you want to get as the second parameter, and the third "Not found" in the case above, the default value should any value in the mapping table matches the current value for Company.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

sbaldwin
Partner - Creator III
Partner - Creator III

had a further throught you could use a mapping load:

group_map:
mapping LOAD Company,
     [Company Group]
FROM
Book1.xls
(biff, embedded labels, table is Sheet2$);


main:
LOAD Company,
     Revenue,
     applymap('group_map',Company,Company) as [Company Group]
FROM
Book1.xls
(biff, embedded labels, table is Sheet1$);

Both have the same affect

Thanks

Steve

Not applicable
Author

Gentlemen; Thanks to all for your answers. I tried the last one of sbaldwin because here I understood the code most. It works fine. Thanks again.