Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

Doubt in Apply Map

Hello friends,

Please find the below Script (Apply Map). I am encountering error in it. I just want to give short names to the region. Please help me on this.


ChangeMap1:

Mapping LOAD * INLINE [

ChangeType,     ChangeName

ASIA, ASIA

NORTH AMERICA, NA,

EUROPE, EU

SOUTH AMERICA, SA];

ApplyMap('ChangeMap',"Region") as [Change in Categories],


HAPPY NEW YEAR TO ALL....

12 Replies
Highlighted
Specialist
Specialist

Hi Viswanathan,

    Advance happy new year!!

     your requirement was not clear,but what my assumption is you want short names in

    [Change in Categories] Field.

    Try this in script:

   

ChangeMap1:

Mapping LOAD *

INLINE [

ChangeType,ChangeName

ASIA, ASIA

NORTH AMERICA, NA,

EUROPE, EU

SOUTH AMERICA, SA];

new table:

load *,

ApplyMap('ChangeMap1',ChangeType,'Not Found') as [Change in Categories]

INLINE [

    ChangeType

    ASIA

    NORTH AMERICA

    EUROPE

    SOUTH

    SOUTH AMERICA

];


By this you can get

img1.png


--Surendra

Highlighted
MVP
MVP

1) You have given Mapping Table name ChangeMap1 and you are using ChangeMap

2) You are using Region within double quote.. You just need to use Region without any quote.


ChangeMap1:

Mapping LOAD * INLINE [

ChangeType,    ChangeName

ASIA, ASIA

NORTH AMERICA, NA,

EUROPE, EU

SOUTH AMERICA, SA];

//Wrong... ApplyMap('ChangeMap',"Region") as [Change in Categories]

//below one is correct.. and should work.

ApplyMap('ChangeMap1',Region,'NotFound') as [Change in Categories]


Go through below link to understand more on ApplyMap.

Don't join - use Applymap instead

https://www.quickintelligence.co.uk/applymap-is-it-so-wrong


Happy Qliking..


Regards,

MK

Highlighted

Manish -

I don't think point number 2 should be a concern. I think double quotes behaves just like square brackets in the script. Tested this with surendraj‌'s script

ChangeMap1:

Mapping LOAD *

INLINE [

ChangeType,ChangeName

ASIA, ASIA

NORTH AMERICA, NA,

EUROPE, EU

SOUTH AMERICA, SA

];

Table:

LOAD *,

    ApplyMap('ChangeMap1', "ChangeType",'Not Found') as [Change in Categories]

INLINE [

    ChangeType

    ASIA

    NORTH AMERICA

    EUROPE

    SOUTH

    SOUTH AMERICA

];

and had no issues running the above. I think the only concern was the name mis-match of the tables.

Highlighted
Contributor III
Contributor III

Sorry friends,

I have not asked my doubt clearly it seems, Consider, in the below table I am having Dist Region and Sales. When I make a PIE chart out of this, the name of the region should be in short forms (Asia, EU, NA, SA). Hope now I am clear with my question.

                  

Dist RegionSales
NORTH AMERICA20000
EUROPE10000
ASIA60000
SOUTH AMERICA20000

Thank you, friends

Now the Time here is 11:55 PM.... Happy New year... May this New year bring you Happiness with long life.

Highlighted
Contributor II
Contributor II

Try this :

Mapping LOAD * INLINE

[

ChangeType,     ChangeName

ASIA, ASIA

NORTH AMERICA, NA,

EUROPE, EU

SOUTH AMERICA, SA] ;

Load *,

ApplyMap('ChangeMap','Region') as Change_in_Categories

;

Highlighted
Contributor III
Contributor III

Hi Surendra Javvaji,

Thanks for yyour reply. I tried your script, the result is shown below

Capture.JPG

Before it was like the below image,

Capture.JPG

Highlighted
Contributor III
Contributor III

This worked for me.

Thank you once again Sunny..

Highlighted
Partner
Partner

I think the issue is with your string, one charachter doesn't match and applymap won't work.

LOAD following table without mapping load and don't use applymap

RegionShortName:

LOAD * INLINE [

Region,ShortName

ASIA, ASIA

NORTH AMERICA, NA,

EUROPE, EU

SOUTH AMERICA, SA

];


In UI create a table with Region, ShortName and Sum(Sales)

Share your output here.

Highlighted
Contributor III
Contributor III

Thanks for your support Shubham Singh

I used the below mentioned script and i worked great.

ChangeMap1:

Mapping LOAD * INLINE [

ChangeType,    ChangeName

ASIA, ASIA

NORTH AMERICA, NA,

EUROPE, EU

SOUTH AMERICA, SA];

Load *,

ApplyMap('ChangeMap1',"Dist Region",'NotFound') as [Change in Categories]

INLINE [

    "Dist Region"

    ASIA

    NORTH AMERICA

    EUROPE

    SOUTH

    SOUTH AMERICA

];