Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Populating a multi-column table with another table

Morning guys

I've got a fairly simple problem, but i cannot get my head around how to resolve this !:

I have 2 tables, 'Main' and 'Task Date'

On my 'Main' table I have a multi column Task Number:

No.Task A NumberTask B NumberTask C Number
110
21516
3202122
4252829
530

On my 'Task Date' table I have 2 columns.

Task NumberTask Date
103- Mar
154 - Mar
167 - Mar
1722 - April
1825 - April

I want to populate the 'Main' table with information from the 'Task Date' table, the finished table should look like:

No.Task A DateTask B DateTask C Date
13- Mar
213- Mar31- Mar
35- Mar22 - April12 - April
414 - April22 - April22 - April
522 - April

What is the easiest way to this without thousands of loops?

Many thanks in advance

1 Solution

Accepted Solutions
marcus_malinow
Partner - Specialist III
Partner - Specialist III

ApplyMap might be a suitable approach.

Do a MAPPING LOAD of the task date table, then when loading the Main table, so multiple ApplyMaps, using the previously loaded date table mapping.

View solution in original post

5 Replies
Ralf-Narfeldt
Employee
Employee

You can either first load the Task Date table, and then use the LookUp function in a preceding load to the Main load where you create the Task A Date... fields

Or you can load Task Date as a mapping table, and then use ApplyMap in the Main load

marcus_malinow
Partner - Specialist III
Partner - Specialist III

ApplyMap might be a suitable approach.

Do a MAPPING LOAD of the task date table, then when loading the Main table, so multiple ApplyMaps, using the previously loaded date table mapping.

Not applicable
Author

Hey Marcus

I took your advice, and did the below:

TaskNum_map:

Mapping load

*

resident TaskNum_date;

temp_final:

NoConcatenate load

*,

ApplyMap('TaskNum_map',[Task A Number]) as [Task A Number],

ApplyMap('TaskNum_map',[Task B Number])   as [Task B Number],

ApplyMap('TaskNum_map',[Task C Number])  as [Task C Number]

Which seems to work magically, but im curious as how ApplyMap works in the background, how does the function know which column to search and which column to replace?

Ie, In "ApplyMap('TaskNum_map',[Task A Number])"

how does it know to search through column "Task No" and replace with "Task Date"

What would happen if both column data type were the same - and if one row of data appears on both the columns?

Task NumberTask Date
18200
17300
200400
15500
10600
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Charlie,

ApplyMap takes as its inputs a mapping table, and a lookup value. The mapping table should be defined as a two column table with a lookup column as it's first column, and a return value as it's second.

Then, when you use the ApplyMap, you're essentially looking up your lookup column, and returning the return value.

It really doesn't matter what data types you use - in fact QlikView is fairly type agnostic anyway. If you have multiple values of your lookup value though you should be aware that ApplyMap will return the first return value that it finds. In this way it differs from something like a Join.

Marcus

Not applicable
Author

Ahh, thanks mate I see, so the first column in Map is always the look-up column, second the value to replace. Perfect mate, clear as day