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

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

ApplyMap Usage

Hi,

Please explain when in which scenario we need to use the applymap ?Please give one simple example.

-Lary

3 Replies
rbecher
MVP
MVP

It's for simple mapping purposes like this:

input => output
1 => A
2 => B
2 => C

Map1:
mapping load * inline [x,y
1,A
2,B
3, C] ;

ApplyMap ( 'Map1', 2 )

returns

B

Ralf

Astrato.io Head of R&D
Anonymous
Not applicable
Author

Lary,

Here is a scenario:
Thre is a table "Users" that contains UserId and UserName. There is another table "Organisations", where there are fields OwnerId, which contains UserId, and ProjectManagerId also contains UserId. And one more table, Orders, with fields AccountId and SalesRepId. You want Orders linked Organizations by AccountId, and not by any users.
to deal with all these multiple User roles, create map:


UserMap:
MAPPING SQL SELECT DISTINCT
UserId,
UserName
FROM Users;

And use it as many times as you want:
applymap('UserMap', OwnerId) as "Account Owner"
applymap('UserMap', ProjectManagerId ) as "SaleProject Manager"
applymap('UserMap', SalesRepId) as "Sales Rep"
...
In the other words, it is used here as a picklist. Not the only possible use of the aplymap, but probably the most typical.

Regards,
Michael

ngulliver
Partner - Specialist III
Partner - Specialist III

Lary.

Have a look at http://www.quickintelligence.co.uk/applymap-is-it-so-wrong/. There is some good info her for applymaps.

Cheers,

Neil