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

How to map Header table fields to Data table data??

Hi Community,

I have 2 tables one is Headers Table and Data Table.

Like

Table1:

CategoryID

CategoryName

Product

Cost

Table2:

100,  Nokia,  N70, 12000

101, Samsung, Sam1, 10500

102, LG, LG1, 2500

103, Apple, Apple1, 25000

How to map these tables??

My Output should be like..

CategoryID, CategoryName, Product, Cost

100,  Nokia,  N70, 12000

101, Samsung, Sam1, 10500

102, LG, LG1, 2500

103, Apple, Apple1, 25000

Thanks in Advance...

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

I assume you are loading from a text file, otherwise you would get the headers from the database field names:

Data:

LOAD *

FROM mysource.csv

(txt, no labels, delimiter is ',');

MapNames:

Mapping LOAD

     '@' & RowNo() As Field,

     HeaderName

;

LOAD @1 As HeaderName

FROM headerlnames.txt

(txt, no labels, delimiter is ',');

Rename Fields using MapNames;

Adapt the loads to your specific environment

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
petter
Partner - Champion III
Partner - Champion III

Please use a more descriptive title for your questions than "Need help". It will help everyone to better spot if it is a request they want to read. If you haven't already looked at the guidelines on how to post on this forum please have a look or please review the good advice you find there.

kind regards

Petter Skjolden

qv_testing
Specialist II
Specialist II
Author

Thanks for Advise .....

qv_testing
Specialist II
Specialist II
Author

HI Jonathan,

If i am use 2 flat files, its working fine, but here

Headers coming from Flat file(CSV)

Data coming from XL file..

Flat file taking like(@1, @2.... so on)

If we have flat files..

Mapping LOAD

     '@' & RowNo() As Field,

     HeaderName

Suppose if i have Excel file like(A, B, C...)

I am using Chr(65) instead of '@'

But how to increase the value for ASCII code....

PFA..

jonathandienst
Partner - Champion III
Partner - Champion III

MapNames:

Mapping LOAD

     Chr(Ord('A') + RowNo() - 1) As Field,

     HeaderName

;

LOAD @1 As HeaderName

FROM headerlnames.txt

(txt, no labels, delimiter is ',');

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