Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
radokotbk
New Contributor

One Field filled with two tables

Hi,

I have to fill the field "Client" of a table like this:

KeySub KeyClient
1232409312054521
1232409311505012
1232409312506543
7245612382602546
7245612381251202
8765462111236549

Where 1 Key can have n Sub Keys. My source tables are something like this:

KeyClient
123240931Client A
724561238Client C

Sub KeyClient
1236549Client D

So my result is:

KeySub KeyClient
1232409312054521Client A
1232409311505012Client A
1232409312506543Client A
7245612382602546Client C
7245612381251202Client C
8765462111236549

Client D

So for each row i have to check if the Key or the Sub Key have a Client associated (i know beforehand that there are no cases where both conditions are true at the same time)

Thank you and sorry for my english.

2 Replies
AlbertoV
Contributor III

Re: One Field filled with two tables

As there are no cases where both conditions are true at the same time. You could left join the first table with Keys, then the one with Sub Keys and then keep the field with a value. See attached qvw


I hope it helps

MVP
MVP

Re: One Field filled with two tables

you can use a nested applymap

1.png

MapKey:

Mapping LOAD * inline [

Key, Client

123240931, Client A

724561238, Client C

];

MapSubKey:

Mapping LOAD * inline [

Sub Key, Client

1236549, Client D

];

Source:

load * inline [

Key, Sub Key

123240931, 2054521

123240931, 1505012

123240931, 2506543

724561238, 2602546

724561238, 1251202

876546211, 1236549

];

Final:

LOAD

  Key,

  [Sub Key],

  ApplyMap('MapKey', Key, ApplyMap('MapSubKey', [Sub Key])) as Client

Resident Source;

DROP Table Source;



Don't join - use Applymap instead


Community Browser