Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
AA240197
Contributor II
Contributor II

ApplyMap doesn't work: why?

Hi guys, I have this script to have as output a text field present in the mapping table:

In your opinion, there are mistakes. Because I've really tried everything, but the applymap always gives me the Null.

I tried to copy and paste the table (inline) and instead it takes the values. So, I wonder, what could be the problem?

 

Mapping
map1:
LOAD 

	codcausale, 
	specifcaus;
    
SELECT "vsql_id",
	"vsql_pk",
	"codcausale",
	"specifcaus",
	"desccaus",
	"codreg",
	"causautom",
	"mastro_iva",
	"conto_iva",
	"sottoc_iva",
	"tipodoc_telematico_fatture",
	"scritture_provvisorie",
	"vsql_user_ins",
	"vsql_user_ultmod",
	"vsql_dataora_ins",
	"vsql_dataora_ultmod"
FROM "okw"."tabcausa";


Giornale:
LOAD 
	vsql_id, 
	vsql_pk, 
	vsql_annocontabile, 
	codcausale, 
	codregcont,
	protocollo, 
	datareg, 
	numdoc, 
	datadoc, 
	descriz, 
	numpartita,
    applymap('map1', codcausale, null()) as New;

SELECT "vsql_id",
	"vsql_pk",
	"vsql_annocontabile",
	"codcausale",
	"codregcont",
	"protocollo",
	"datareg",
	"numdoc",
	"datadoc",
	"descriz",
	"numpartita"
FROM "okw"."giornale";

 

(Codcausal is a text type field)

Labels (1)
9 Replies
theoat
Partner - Creator III
Partner - Creator III

The good syntaxe is
map1:
Mapping Load

Not 
Mapping
map1:
Load

So you can try this :

map1:
Mapping LOAD 

	codcausale, 
	specifcaus;
    
SELECT "vsql_id",
	"vsql_pk",
	"codcausale",
	"specifcaus",
	"desccaus",
	"codreg",
	"causautom",
	"mastro_iva",
	"conto_iva",
	"sottoc_iva",
	"tipodoc_telematico_fatture",
	"scritture_provvisorie",
	"vsql_user_ins",
	"vsql_user_ultmod",
	"vsql_dataora_ins",
	"vsql_dataora_ultmod"
FROM "okw"."tabcausa";


Giornale:
LOAD 
	vsql_id, 
	vsql_pk, 
	vsql_annocontabile, 
	codcausale, 
	codregcont,
	protocollo, 
	datareg, 
	numdoc, 
	datadoc, 
	descriz, 
	numpartita,
    applymap('map1', codcausale, null()) as New;

SELECT "vsql_id",
	"vsql_pk",
	"vsql_annocontabile",
	"codcausale",
	"codregcont",
	"protocollo",
	"datareg",
	"numdoc",
	"datadoc",
	"descriz",
	"numpartita"
FROM "okw"."giornale";



Enjoy your Qlik.

Kind regards,
Théo ATRAGIE.

PhanThanhSon
Creator II
Creator II

Hi,

try this:

 

map1:
Mapping LOAD 

	codcausale, 
	specifcaus;
    
SELECT 
	"codcausale",
	"specifcaus"
	
FROM "okw"."tabcausa";


Giornale:
LOAD 
	vsql_id, 
	vsql_pk, 
	vsql_annocontabile, 
	codcausale, 
	codregcont,
	protocollo, 
	datareg, 
	numdoc, 
	datadoc, 
	descriz, 
	numpartita,
    applymap('map1', codcausale, null()) as New;

SELECT "vsql_id",
	"vsql_pk",
	"vsql_annocontabile",
	"codcausale",
	"codregcont",
	"protocollo",
	"datareg",
	"numdoc",
	"datadoc",
	"descriz",
	"numpartita"
FROM "okw"."giornale";

 

Best regards Son

 

AA240197
Contributor II
Contributor II
Author

Thank You!

I fixed it as you suggested, but it still doesn't work properly. That is absurd, because if I create the same table with the INLINE command, copying and pasting the two fields, the mapping works.

 

map1:
Mapping
LOAD 
	codcausale, 
	specifcaus;
    
SELECT "vsql_id",
	"vsql_pk",
	"codcausale",
	"specifcaus",
	"desccaus",
	"codreg",
	"causautom",
	"mastro_iva",
	"conto_iva",
	"sottoc_iva",
	"tipodoc_telematico_fatture",
	"scritture_provvisorie",
	"vsql_user_ins",
	"vsql_user_ultmod",
	"vsql_dataora_ins",
	"vsql_dataora_ultmod"
FROM "okw"."tabcausa";



Tabella1:
LOAD 
	vsql_id, 
	vsql_pk, 
	vsql_annocontabile, 
// 	codcausale, 
	codregcont,
	protocollo, 
	datareg, 
	numdoc, 
	datadoc, 
	descriz, 
	numpartita,
    ApplyMap('map1', codcausale, 'nessuno') as New;

SELECT "vsql_id",
	"vsql_pk",
	"vsql_annocontabile",
	"codcausale",
	"codregcont",
	"protocollo",
	"datareg",
	"numdoc",
	"datadoc",
	"descriz",
	"numpartita"
FROM "okw"."giornale";

 

theoat
Partner - Creator III
Partner - Creator III

Add noconcatenate before the creation of your mapping table.

AA240197
Contributor II
Contributor II
Author

Very kind.

 

Can you please confirm that I have well understood the position of the noconcatenate?

map1:
Mapping
LOAD 
codcausale, 
specifcaus;
    
FROM "okw"."tabcausa";
 
NoConcatenate
 
Tabella1:
LOAD 
vsql_id, 
vsql_pk, 
vsql_annocontabile, 
// codcausale, 
codregcont,
protocollo, 
datareg, 
numdoc, 
datadoc, 
descriz, 
numpartita,
    ApplyMap('map1', codcausale, 'nessuno') as New;
 
SELECT "vsql_id",
"vsql_pk",
"vsql_annocontabile",
"codcausale",
"codregcont",
"protocollo",
"datareg",
"numdoc",
"datadoc",
"descriz",
"numpartita"
FROM "okw"."giornale";

 

AA240197
Contributor II
Contributor II
Author

I removed the "mapping" statement, using a drop table at the bottom, and that's the only way it works at the moment.

 

I used the exact same logic with two other mapping tables and no problem. This one, on the other hand, does not want to know anything about working in the traditional way.

Adam_Romanowski
Partner - Contributor III
Partner - Contributor III

Try to remove semicolon from mapping load:

map1:
Mapping
LOAD 
codcausale, 
specifcaus    
FROM "okw"."tabcausa";
and I'm not sure, but applymap checks for data types. If you have codcausale in map1 loaded as text (interpreted by Qlik) and codcausale in Tabella1 as number, applymap may fail. But firstly, remove semicolon.
AA240197
Contributor II
Contributor II
Author

Thank you for your reply.

I removed the mapping statement and everything seems to be working properly.

I wonder, once a mapping is set up, to add other mappings (a second, third and so on) it is necessary to repeat the "mapping" command or can Qlik read it by itself, if the mappings are consecutively columned?

marcus_sommer

Each mapping table needs a separate mapping statement and will create an own independent table which are automatically removed when the script has finished.

There is no limitation how many mapping tables are created.