Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
andreas_ar
Contributor II
Contributor II

ApplyMap() on a newly created Field

Hi everyone,

I'm facing a problem with the ApplyMap() script-function.

I'm using an Inline table to map groups to different codes like this:

Mapping_Ausschusscodes:

Mapping LOAD * INLINE [
AS_CODE , Auschussgruppe
Code1 , Gruppe1
Code2 , Gruppe1
Code3 , Gruppe2
Code4 , Gruppe2
Code5 , Gruppe1
]
;

 In my facttable it looks like this:

Ausschuss:
LOAD * AS_CODE 
AS     Ausschusscode,
       ApplyMap('Mapping_Ausschusscodes' , AS_Code , 'Fehler') 
AS     Ausschussgruppe
       ...
FROM   Ausschuss.qvd (qvd)
;

In addition to that I want to map colours to the different Groups so I built a table like this:

Farbcodes_Ausschussgruppen_tmp:
LOAD * INLINE [
       Ausschussgruppe , Red , Green , Blue
       Gruppe1         , 0   , 80    , 140
       Gruppe2         , 255 , 255   , 0
]
;

Mapping_Clr_AS_Gruppe:
MAPPING LOAD Ausschussgruppe,
             RGB(Red,Green,Blue)
AS           Clr_AS_Gruppe
RESIDENT     Farbcodes_Ausschussgruppen_tmp
;

Drop table   Farbcodes_Ausschussgruppen_tmp
;

 

In the ende the code in the facttable looks like this:

Ausschuss:
LOAD * AS_CODE as Ausschusscode,
       ApplyMap('Mapping_Ausschusscodes' , AS_Code , 'Fehler') 
AS     Ausschussgruppe
//     ...
FROM   Ausschuss.qvd (qvd)
;
/*I made an extra table for the colourcoding because I could not apply the map on the newly created field 'Ausschussgruppe'*/

Farbcodierung:
LOAD     Ausschussgruppe,
         ApplyMap('Mapping_Clr_AS_Gruppe' , Ausschussgruppe , RGB(90,91,90))
AS       Clr_AS_Gruppe
RESIDENT Ausschuss
;

Now QlikView creates a synthetic Key, I think because of the double use of 'Ausschussgruppe'. Is there a way to apply the colourmap to the newly created field without creating a synthetic key/table?

 Or is there a way to integrate the RGB-Codes into the first mappingtable?

Thanks in advance! 🙂

AR

1 Solution

Accepted Solutions
martinpohl
Partner - Master
Partner - Master

map both steps in one line

ApplyMap('Mapping_Clr_AS_Gruppe' , ApplyMap('Mapping_Ausschusscodes' , AS_Code , 'Fehler') , RGB(90,91,90))
AS       Clr_AS_Gruppe

regards 

View solution in original post

2 Replies
martinpohl
Partner - Master
Partner - Master

map both steps in one line

ApplyMap('Mapping_Clr_AS_Gruppe' , ApplyMap('Mapping_Ausschusscodes' , AS_Code , 'Fehler') , RGB(90,91,90))
AS       Clr_AS_Gruppe

regards 

andreas_ar
Contributor II
Contributor II
Author

Thanks for your quick answer. It works. Didn't know that ApplyMap can be nested. 🙂