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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
bismart
Creator
Creator

Only load referenced fields from database table

Hi all

I wish to load only the fields identified with flag = Y from an Excel sheet which determines which fields should be loaded from a database table.

Excel Doc Example

FieldName                Flag              

CustomerID                 Y    

ProductID                    Y

ProductCategory          N

ProductSubCat            N

Now I want to load only the fields identified with Flag = Y from database Table...

I have tried something like this

//=================================================

temp:

Load FieldName as XXX

From

Excel

where Flag = 'Y'

Table:

Load

fieldname

from

databasetable

where exists ( XXX , fieldname );

DROP Table temp;

//=================================================

The result I want is that only the two fields from the database table (CustomerID and ProductID)

are loaded into the table.

Any ideas?

Thanks

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

How about:

temp:

LOAD concat(FieldName,',') as FieldList

From Excel

where Flag = 'Y'

;

LET vFieldList=peek('FieldList');

DROP TABLE temp;

mytable:

LOAD

     $(vFieldList)

FROM database.table

;

-Rob

http://masterssummit.com

http://robwunderlich.com

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

How about:

temp:

LOAD concat(FieldName,',') as FieldList

From Excel

where Flag = 'Y'

;

LET vFieldList=peek('FieldList');

DROP TABLE temp;

mytable:

LOAD

     $(vFieldList)

FROM database.table

;

-Rob

http://masterssummit.com

http://robwunderlich.com

bismart
Creator
Creator
Author

Thanks Rob

Works a treat...

Appreciate you taking the time to provide solution

Cheers

Dave