Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Apply Map not working

Hi All,

I have been trying to use ApplyMap in QlikSense and I followed many examples. But it's not working properly and I'm not getting the desired output.

Following is the script that I'm using:

MonthMap:

Mapping LOAD * INLINE

[    MonthName, MonthNum      

     Jan, 1   

     Feb, 2   

     Mar, 3

     Apr, 4   

     May, 5   

     Jun, 6   

     Jul, 7   

     Aug, 8   

     Sep, 9   

     Oct, 10   

     Nov, 11   

     Dec, 12

];

Orders:

LOAD

    OrderID,

    OrderDate,

    Month(OrderDate) as "MonthName",

    CustomerID,

    EmployeeID,

    ShipperID,

    ProductID,

    Sales,

    "COS",

    GP,

    Quantity,

    Discount,

    Freight

FROM [lib://Data/Orders - Copy.xls]

(biff, embedded labels, table is Orders$);

Temp:

Load Distinct *,

ApplyMap('MonthMap',MonthName,'No Month') as Month_Num

Resident Orders;

Drop table Orders;

Any help regarding this will be highly appreciated.

Best Regards,

Mohit Kumar

14 Replies
sunny_talwar

The script posted above doesn't seem to have any issues (I think), unless you are able to share a sample, it would be difficult to suggest anything

swuehl
MVP
MVP

You may need to match the text() part of your MonthName to the mapping key field:

MonthMap:

MAPPING

LOAD * INLINE

[    MonthName, MonthNum   

    Jan, 1

    Feb, 2

    Mar, 3

    Apr, 4

    May, 5

    Jun, 6

    Jul, 7

    Aug, 8

    Sep, 9

    Oct, 10

    Nov, 11

    Dec, 12

];

Orders:

LOAD

    OrderID,

    OrderDate,

     ApplyMap('MonthMap', Text(Month(OrderDate)), 'not found') as MonthNum,

    Month(OrderDate) as "MonthName",

    CustomerID,

    EmployeeID,

    ShipperID,

    ProductID,

    Sales,

    "COS",

    GP,

    Quantity,

    Discount,

    Freight

FROM [lib://Data/Orders - Copy.xls]

(biff, embedded labels, table is Orders$);

sunny_talwar

I guess that could be the issue. Can we also change the Mapping load to make sure MonthName is dual Month?

MonthMap:

MAPPING

LOAD Month(Date#(MonthName, 'MMM')) as MonthName,

          MonthNum;

LOAD * INLINE

[    MonthName, MonthNum

    Jan, 1

    Feb, 2

    Mar, 3

    Apr, 4

    May, 5

    Jun, 6

    Jul, 7

    Aug, 8

    Sep, 9

    Oct, 10

    Nov, 11

    Dec, 12

];

Not applicable
Author

Hi Swuehl,

This worked!! Thank you very much for your help!

Best Regards,

Mohit Kumar

swuehl
MVP
MVP

Yes, this should also work, though I've seen very few issues with mapping a dual value, and less with pure text or numeric values.