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

Rename data within a table

I have the following .qvd data loaded into my data model:

   

ADJ_NAMECLM_STATUSCOV_CODE
BOB JONESCLGD
JAMES SMITHCLAD
SANDRA HARVYCLAB

In my data model script I am renaming,

ADJ_NAME as Name,

CLM_STATUS as Status,

COV_CODE as Injury

I would like to rename the data within the table-- CL to Closed, GD to General Liability, etc...

How is this possible?

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Perhaps like this:

mapReplace:

MAPPING LOAD * INLINE [

Old, New

CL, Closed

GD, General Liabillity

etc....

];

MyData:

LOAD

     ADJ_Name as Name,

     ApplyMap('mapReplace',CLM_STATUS) as Status

     ApplyMap('mapReplace',COV_CODE) as Injury

FROM

     ....source_qvd...

     ;

If a value CL occurs in both CLM_STATUS and COV_CODE, but should be replaced by different values then you need to use two mapping tables instead of only the one in the example code above.


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Gysbert_Wassenaar

Perhaps like this:

mapReplace:

MAPPING LOAD * INLINE [

Old, New

CL, Closed

GD, General Liabillity

etc....

];

MyData:

LOAD

     ADJ_Name as Name,

     ApplyMap('mapReplace',CLM_STATUS) as Status

     ApplyMap('mapReplace',COV_CODE) as Injury

FROM

     ....source_qvd...

     ;

If a value CL occurs in both CLM_STATUS and COV_CODE, but should be replaced by different values then you need to use two mapping tables instead of only the one in the example code above.


talk is cheap, supply exceeds demand
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

You can do :

[...]

Pick(Match(CLM_STATUS, 'CL', 'GD'), 'Closed', 'General Liabilit') as Status,

Pick(Match(COV_CODE, 'CL', 'GD'), 'Closed', 'General Liabilit') as Injury,

[...]

OR

_MAP_

MAPPING LOAD * INLINE [

  CODE, LABEL

  CL, Closed

  GD, General Liabilit

];

LOAD

  ApplyMap('_MAP_', CLM_STATUS) as Status,

  ApplyMap('_MAP_', COV_CODE) as Injury,

[...]

Help users find answers! Don't forget to mark a solution that worked for you!
shree909
Partner - Specialist II
Partner - Specialist II

Hi,

You can do this by using applymap function

Create  2 mapping loads for status and injury

Status:

Mapping Load  * Inline [

Status,Description

CL,Closed

];

COVCode:

Mapping Load  * Inline [

COVCode,Description

GD,General Liability

AD ,ADDescription

AB,ABdescription

];

Table:

LOAD ADJ_NAME  AS Name,

     ApplyMap('Status',CLM_STATUS,'Unknown')  AS Status,

      ApplyMap('COVCode',COV_CODE,'Unknown')  AS Injury

    

FROM

[https://community.qlik.com/thread/220240]

(html, codepage is 1252, embedded labels, table is @1);

Not applicable
Author

Hi,

I have not used Pick(Match( before. What is the difference int he Apply Map and the Pick Match?

Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Pick(Match(Field, 'Val1', 'Val2'), 'Value1', 'Value2'))

is like a

If(Field = 'Val1', 'Value1', If(Field = 'Val2', Value2))

In your case the mapping load/ applymap is better (performance and maintenance)

Help users find answers! Don't forget to mark a solution that worked for you!