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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to create one field from the table based on 2 different fields

Hi,

i have 2 fields in one table, need to derive one more field based on the 2 existing fields, please suggest me how to achieve this.

10 Replies
simenkg
Specialist
Specialist

Field1 + Field2 as Field3, //Returns the sum of the two fields

Field1 & Field2 as Field4, //Returns the concatenated string of the two fields.

You should get the picture.

Not applicable
Author

Hi Savi,

a bit more detail on what you are trying to get as your end result would be good.

If you are just trying to combine the two fields, you can use '&' and alias as a new field.

eg. FieldA & FieldB As Field C

Or with a separator FieldA & '|' & FieldB As FieldC

hope that help

Joe

its_anandrjs
Champion III
Champion III

Hi,

If this fields are string or number you can concatenate this fields or if conditionally you can to create it you can do this in the load script

Load

Field1,

Field2,

Field1&'-'&Field2 as Newfield

From Location;

Or

Load

Field1,

Field2,

If(Field1=2 and Field2 <= 5,Field1,Field2)  as Newfield

From Location;

It depends on the conditions. Provide if you have any sample date.

Regards

Anand

Kushal_Chawda

what exactly you want to calculate?

Not applicable
Author

book2.png

anbu1984
Master III
Master III

For field2 <> b, how do you derive output?

its_anandrjs
Champion III
Champion III

Write like

Load

Field1,

Field2,

if( Field2 = 'b','y')  as OP

From Location;

With your snap shot not understood provide any sample for this in any inline table or excel file for exlanation

Regards

Anand

Not applicable
Author

if field2 has 'b' then for all field1 records having 'x' o/p should be 'Y'

if field2 doesn't have 'b' then for all field1 records having 'x' o/p should be 'N'

its_anandrjs
Champion III
Champion III

Why not you directly check the Field1 for this.

or you can try

LOAD Field1,Field2,if(Field2='b','Y','N') as Flag,RowNo() as RID;

LOAD * Inline

[

Field1,Field2

x,a

x,a

x,a

x,b

x,b

y,a

y,a

y,a

y,b

y,b

]

Regards

Anand