Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

b_garside
Valued Contributor

Combine multiple fields into one common field

I have several Race fields that should be combined into one common field since they have a common attributes.

The problem is how do I combine the Six fields when they have a Y/N value for each one and map it to the label of the fields?

Current Schema:

FieldValue
Race: WhiteY/N
Race: BlackY/N
Race: HispanicY/N
Race : AsianY/N
Race : IndianY/N
Race: OtherY/N
Convert to This:
Values
RaceWhite
Black
Hispanic
Asian
Indian
Other
Tags (2)
4 Replies

Re: Combine multiple fields into one common field

Hi,

Please explain the field names or you can use subfield here

This data in which two fields

Current Schema:

Race: WhiteY/N
Race: BlackY/N
Race: HispanicY/N
Race : AsianY/N
Race : IndianY/N
Race: OtherY/N

Regards

Anand

b_garside
Valued Contributor

Re: Combine multiple fields into one common field

If I have 6 fields that have 6 Y/N values I want to convert them into one field that has the descriptions instead.

I can create a mapping table as well to help.

Would like the data to be stored like this.

FieldValue
RaceWhite
Black
Hispanic
Asian
Indian
Other

Re: Combine multiple fields into one common field

Can you explain with table structure that will be great.

Regards

Anand

prieper
Honored Contributor II

Re: Combine multiple fields into one common field

You may use a crosstable-approach, but with this limited amount of criteria, would go with a plain approach:

Data:

LOAD

  Attrib1,

  Attrib2,

  IF(IsWhite = 'y', 'White') & IF(IsBlack = 'y', 'Black') & IF(IsIndian = 'y', 'Indian') AS Race

INLINE [Attrib1, Attrib2, IsWhite, IsBlack, IsIndian

     a, aa, y, n, n

     b, bb, y, n, n

     c, cc, n, y, n

     d, dd, n, n, y];

HTH Peter

Community Browser