Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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$);
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
];
Hi Swuehl,
This worked!! Thank you very much for your help!
Best Regards,
Mohit Kumar
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.
@swuehl Thank you so much for your answer, I was facing the same problem today and I fixed it using text() for both the mapping's field and the column, the strange thing is was working fine two days ago.