Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

IF left or right function

Hi.

What is the best way in the script to do some string functions like this,

if some places are with North or north (like london north or Dublin south) I would like to have the result "N" or "S".

Thanks in advance!

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

You could try a mapping like:

map1:

Mapping load * Inline [

x, y

Norra, N

Södra, S

norra, N

södra, S

];

Then for your field do:

MapSubString('map1', Station) as Station

Hope this helps!

View solution in original post

11 Replies
MK_QSL
MVP
MVP

Capitalize(Left(Subfield(YourFieldName,'  ',2),1))

Something like below...

=Capitalize(Left(Subfield('Dublin  south','  ',2),1))

Not applicable
Author

Björn,

Wildmatch() could suit you

Fabrice

Not applicable
Author

I tried with:

if(wildmatch(station,'*North*'), 'N',

  if(wildmatch(station,'*north*'),'N',

  if(wildmatch(station,'*South*'),'S',

  if(wildmatch(station,'*south*'),'S')))) as StationLink

But it doesen't give me the result I want. I have a field with many stations end I want to "wash" the field so that every station have a N or a S if they have two (or more) ways to exit the station.

MK_QSL
MVP
MVP

Give us some example of your station field...

If my solution is not working?

Not applicable
Author

See attached example.

jerem1234
Specialist II
Specialist II

Maybe something like this?

pick(wildmatch(Station, '*Norra*', '*Södra*')+1, Station, 'N', 'S')

I wasn't sure what do to do if the name didn't have either north or south in it, so if it didn't it just returns the station name.

Hope this helps!

Not applicable
Author

That one is not working. I'm looking for the station name and the N or S as London N.

jerem1234
Specialist II
Specialist II

Just to try and understand your requirements a little more, you want

'Bergshamra Norra' to be 'Bergshamra N'

and

'Bergshamra Södra' to be 'Bergshamra S'

?

What about if there is no South or North, you want just:

'Duvbo' to be 'Duvbo'

?

What if there is a North in the middle:

'Gardet Norra AU 1' to be 'Gardet AU 1 N'

?

Or do you want a field with just station and no directions, and then another field with either N, S, or null?

Can you describe it a little more?

Not applicable
Author

Yes you have understand the requirement right. If the station have a direction it should be N or S.