Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

gregoryt40
New Contributor

Rename records based on values

Is there a way in the script to rename records based on values.  i.e. in the field 'Type', I want any 1 to equal 'Private', 2 to equal 'General', etc.

Thank you!

1 Solution

Accepted Solutions

Re: Rename records based on values

Did you add semi-colon (Smiley Wink after  ] at the end?

FromTo:

Mapping

LOAD * Inline [

From, To

1,General PII

2,Sensitive PII

3,Financial Information

4,Medical Information

5,Multiple Types

];

17 Replies

Re: Rename records based on values

Have a look at the ApplyMap() function.

This Blog Post Joins and Lookups explains it as well as a few other things.

sergiorey
New Contributor III

Re: Rename records based on values

Hi Tyler,

You can do it this way:

If([Type]=1, 'Private', If([Type]=2, 'General', [Type]))          As [Type]

Hope it helps.

Regards,

Sergio.

Re: Rename records based on values

Try this:

Pick(Match(Type, 'Private', 'General'), 1, 2) as NewType

eduardo_sommer
Valued Contributor

Re: Rename records based on values

Use an ApplyMap function

First, load the table with the from/to columns

FromTo:

Mapping load * inline [

From, To

1, Private

2, General

...

...

];

Table:

Load

      Field1,

      Field2,

     ApplyMap('FromTo', Type, 'Default Value') as Type,

...

...

From ...;  

Eduardo

gregoryt40
New Contributor

Re: Rename records based on values

None of these are working unfortunately. 

It tells me that it does not recognize the 'Type' field when I apply these methods.  Any other thoughts?

sergiorey
New Contributor III

Re: Rename records based on values

Is it working when loading "Type" field without transformations?

Re: Rename records based on values

So you don't have a field called Type. What is the name of the field that contains Private, General etc?

Re: Rename records based on values

Can you post your script?

Re: Rename records based on values

Hi,

I guess this thread is related to your previous thread: Count total of 1s, 2s, 3s, 4s, and 5s in single expression

So maybe you are having a field [Type of PII] instead you could use in those expressions?

hope this helps


regards


Marco

Community Browser