Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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
Contributor III

Re: Renaming either of 2 fields as a new field

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.

4 Replies
Employee
Employee

Re: Renaming either of 2 fields as a new field

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

Change_Station=''

MVP
MVP

Re: Renaming either of 2 fields as a new field

Try

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

magavi_framsteg
Contributor III

Re: Renaming either of 2 fields as a new field

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

Re: Renaming either of 2 fields as a new field

Thanks to all replies and the quick response.

The second method worked using the >=1

Thanks again.

Alex

Community Browser