Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problems using ApplyMap function

Hi! This is pretty simple, but it is giving me a lot of problems. Suppose the following map definition:

map1:

mapping load * inline

[x , y

AAA, A

AA, A

A, A

]

Then I try to include a field in a straight table with the following calculation: applymap('map1',value), being value AAA, AA, or A. The thing here is that the function returns NULL.

Seams dull, but I can't make it work. Any help will be greatly appreciated.

Regards,

Gilberto.

1 Solution

Accepted Solutions
rbecher
MVP
MVP

Gilberto,

remove the last line A, A from the map, because it's obsolete. See attachment also.

- Ralf

Astrato.io Head of R&D

View solution in original post

8 Replies
Not applicable
Author

Hi,

could you post an example, I cant find an error.

Regards Alex:)

Miguel_Angel_Baeyens

Using ApplyMap('Map1','AAA') will give you 'A'. It seems to me that your inline map table should be A,AAA, A,AA and so.

(I leave the original post just for edit purposes, but forget about it)

When applying a map, you don't have to use if against a value, but agaist a field, which means

ApplyMap('map1',x,'default value')


Will work as in your map, the name of the field you want to replace is "x". When "x" takes the value of "AAA" it will be replaced by "A" following your map. If no value is found in your map, "default value" as string will replace the actual value you are working with.

Hope it helps and sorry the misunderstanding.

Not applicable
Author

Miguel, thank you for the reply. In fact, I am trying to use a field which values are AAA, AA, A. When I try to display the mapping in a straight table, the applymap function returns a null value even if I use a default value (e.g. 'Z').

rbecher
MVP
MVP

Gilberto,

remove the last line A, A from the map, because it's obsolete. See attachment also.

- Ralf

Astrato.io Head of R&D
Miguel_Angel_Baeyens

You are getting null because you probably are applying the map on the map? As Ralf points, you need to separate map from data, then applymap on data.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP


Gilberto Ruiz wrote:Then I try to include a field in a straight table with the following calculation: applymap('map1',value),


ApplyMap() is a script only fucnction. It cannot be used in charts. MAPPING tables are automatically dropped at script end.

-Rob

Not applicable
Author

Ralf, the file you provided solved the mapping problem. Thank you. Now, here comes the second part of the problem:

Suppose an Excel file with 2 columns:

AAA, 100

AA, 10

BBB, 100

BB, 5

With the mapping, I am able to change the AAA and AA to A (as well the BBB and B to B) and keep the outcome in a new field (let's say, Field2). Then how can I link Field2 with the values 100, 10, 100, 5 so in a graph appears 110 for A (the sum of AAA and AA) and 105 for B (the sum of BBB and BB).

rbecher
MVP
MVP

Then you need two mappings. The first one for A, B (Field1) the second for the figures (Field2). Then take Field1 as dimension and sum(Field2).

Astrato.io Head of R&D