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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

qlikview load- setting a field name by condition

Hi !!

i have 2 tables in my DB:

a:

a.ida.nameb.idb.name
1a11b1
2a22b2
3a33b3

c:

c.idc.typea.idb.idc.name
1a13a1
2a22a2
3b21b1

i want to fill the column c.name in this method:

if c.type=a then fill c.name with a.name

if c.type=b then fill c.name with b.name

its like doing a join between two tables, sometimes on a.id and sometimes on b.id

Thanks !!

Mor

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I think there are multiple approaches.

You can join your first table to the second in two steps, first join a.id / a.name then b.id / b.name,

then filter your resulting table using c.type and remove the fields not necessary.

Or use lookup() function:

First load your first table.

In the second table load, use the lookup function:

LOAD c.id,

          c.type,

          a.id,

          b.id,

          if(c.type = 'a', lookup('a.name','a.id',a.id,'FirstTableName'),

                    lookup('b.name','b.id',b.id,'FirstTableName') )

                              as c.name

FROM SecondTable;

drop FirstTableName;

View solution in original post

2 Replies
swuehl
MVP
MVP

I think there are multiple approaches.

You can join your first table to the second in two steps, first join a.id / a.name then b.id / b.name,

then filter your resulting table using c.type and remove the fields not necessary.

Or use lookup() function:

First load your first table.

In the second table load, use the lookup function:

LOAD c.id,

          c.type,

          a.id,

          b.id,

          if(c.type = 'a', lookup('a.name','a.id',a.id,'FirstTableName'),

                    lookup('b.name','b.id',b.id,'FirstTableName') )

                              as c.name

FROM SecondTable;

drop FirstTableName;

Not applicable
Author

the lookup function workes !!

thanks man !