Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Renaming either of 2 fields as a new field

Hi,

New to Qlikview so please bear with me.  As an example of what I'm after, say I have the following fields in my data:

On_Station

Off_Station

Change_Station

Passengers

Where there is an entry in Change_Station I want to use this field.  If there isn't any data in that field I want to use On_station.  I've tried:

 

if(Change_Station=''',On_Station,Change_Station) as BoardingStation

This only brings across the BoardingStation where data is in the Change_Station field.  No doubt I'm making a basic mistake here but any help would be appreciated.

Thanks

Alex

1 Solution

Accepted Solutions
magavi_framsteg
Partner - Creator III
Partner - Creator III

Hi alexfinkel.

It seems right at first, although your quotes could be the result of a different encoding on your side.

And to make sure the field Change_Station is really empty, you could try this to check if it's empty or if it contains data.

The below code will obviosly give you a new field called BoardingStation containing either On_Station or Change_Station.

if(len(trim(Change_Station)) = 0, On_Station, Change_Station) as BoardingStation

Or this:

if(len(trim(Change_Station)) >= 1, Change_Station, On_Station) as BoardingStation

Or this:

if(trim(Change_Station) = '', On_Station, Change_Station) as BoardingStation

Kind regards

Magnus Åvitsland

BI Architect Consultant

Framsteg Business Intelligence Corp.

View solution in original post

4 Replies
nam
Former Employee
Former Employee

=if(Change_Station='',On_Station,Change_Station) .. you are using double quotes, it should be single quotes

Change_Station=''

swuehl
MVP
MVP

Try

if( len(trim(Change_Station))=0,On_Station,Change_Station) as BoardingStation

magavi_framsteg
Partner - Creator III
Partner - Creator III

Hi alexfinkel.

It seems right at first, although your quotes could be the result of a different encoding on your side.

And to make sure the field Change_Station is really empty, you could try this to check if it's empty or if it contains data.

The below code will obviosly give you a new field called BoardingStation containing either On_Station or Change_Station.

if(len(trim(Change_Station)) = 0, On_Station, Change_Station) as BoardingStation

Or this:

if(len(trim(Change_Station)) >= 1, Change_Station, On_Station) as BoardingStation

Or this:

if(trim(Change_Station) = '', On_Station, Change_Station) as BoardingStation

Kind regards

Magnus Åvitsland

BI Architect Consultant

Framsteg Business Intelligence Corp.

Not applicable
Author

Thanks to all replies and the quick response.

The second method worked using the >=1

Thanks again.

Alex