Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sifatnabil
Specialist
Specialist

Applymap with 2 fields not working

Hi,

I have a mapping table like this:

MarketIDCustNoMcodeMname
7643*2314ABDD
5643*2352EWTG
4456742643AFJK
745543436GGGE

*Note: CustNo is only unique per MarketID; Mcode is totally unique however.

In my main table, I have CustNo and MarketID, and I wish to use applymap to get the Mname

I used:

MAPPING LOAD

     MarketID & ':' & CustNo as ID,

     Mname

Resident mappingtable;

However this is not working. I tested that the mapping table created returns more than 1 row for each ID:

applymap.PNG.png

Why does this happen?

6 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

MAPPING LOAD

     MarketID & ':' & CustNo as ID,

     MaxSTring(Mname) AS Mname

Resident mappingtable

Group By MarketID & ':' & CustNo;

or you can use MinString(), but this will pull one value among many values, it is similar to Max(). Hope this helps you.

Regards,

Jagan.

sifatnabil
Specialist
Specialist
Author

Hi,

This is still not working. FYI the mappingtable is a joined table from 2 sources, might that be the issue?

mappingtable:

LOAD

       CUSTNO,

       MISCODE,

       MARKETID;

SQL SELECT

       CUSTNO,

       MISCODE,

       MARKETID

FROM

  customer.CUST_TBL;

join

LOAD

       MCODE as MISCODE,

       MNAME;

SQL SELECT

       MCODE,

       MNAME

FROM

  customer.MISC_TBL;

^I am loading the mapping load from here.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Temp:

LOAD

       MARKETID & '_' & CUSTNO AS Key,

       MISCODE;     

SQL SELECT

       CUSTNO,

       MISCODE,

       MARKETID

FROM

  customer.CUST_TBL;

join

LOAD

       MCODE as MISCODE,

       MNAME;

SQL SELECT

       MCODE,

       MNAME

FROM

  customer.MISC_TBL;


DROP TABLE Temp;

MappingTableName:

MAPPING LOAD

     Key,

     MaxSTring(MNAME) AS Mname

Resident Temp

Group By Key;

Hope this helps you.

Regards,

jagan.



sifatnabil
Specialist
Specialist
Author

Thanks Jagan, but this is still not working - it's giving the incorrect mappings like before. Is there any other way to achieve the correct mapping?

jagan
Luminary Alumni
Luminary Alumni

Hi,

If possible attach some sample data, it is difficult to tell.

Regards,

Jagan.

sifatnabil
Specialist
Specialist
Author

Please find attached. It seems to work here but not with the SQL databases!