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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Little Syntax trouble shorten names

Hello you all,

Situation: I've got 3 regions and I want to shorten the region names. Now they are called region losser, region almelo and region enschede and I want to get rid of the word region. My script only works for 1 region. Can someone help me with the correct syntax?

IF

(Trim([DTZC Region])= 'Region Losser', 'Losser',[DTZC Region]) , IF(Trim([DTZC Region])= 'Region Almelo', 'Almelo',[DTZC Region]) , IF(Trim([DTZC Region])= 'Region Enschede', 'Enschede',[DTZC Region]) as [DTZC Region],





Labels (1)
1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Richard

If you don't want to go the mapping approach (which would be better for many regions, but not so critical for 3), then use this expression:

If (Trim([DTZC Region])= 'Region Losser', 'Losser',
If(Trim([DTZC Region])= 'Region Almelo', 'Almelo',
If(Trim([DTZC Region])= 'Region Enschede', 'Enschede','')))

OR even

Replace([DTZC Region], 'Region ', '')

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

6 Replies
Not applicable
Author

Check out 'map' and 'mapping' in the help.

Regards,

Gordon

jonathandienst
Partner - Champion III
Partner - Champion III

Richard

If you don't want to go the mapping approach (which would be better for many regions, but not so critical for 3), then use this expression:

If (Trim([DTZC Region])= 'Region Losser', 'Losser',
If(Trim([DTZC Region])= 'Region Almelo', 'Almelo',
If(Trim([DTZC Region])= 'Region Enschede', 'Enschede','')))

OR even

Replace([DTZC Region], 'Region ', '')

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thx Jonathan, this works perfect!

Not applicable
Author

Got another one. It seems that I do not have 3 Regions but 4. The fourth is called Amsterdam (without the word Region). With the formula you gave me, I now only see Region Losser, Almelo and Enschede. The fouth one is missing. Is there a way to get it without naming it into the formula? I do not want to name it because in the futuren there will be more regions without the word Region.

thx in advance

jonathandienst
Partner - Champion III
Partner - Champion III

Richard

Use this:

If (Trim([DTZC Region])= 'Region Losser', 'Losser',
If(Trim([DTZC Region])= 'Region Almelo', 'Almelo',
If(Trim([DTZC Region])= 'Region Enschede', 'Enschede',[DTZC Region])))

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
hector
Specialist
Specialist

Hi, if the field value is always "Region XXXX" there are other options

  1. SubField(FIELD,' ',2) as [DTZC Region]
  2. right(FIELD,Index(FIELD,' ',1)-1)

just to expand the options 😉

rgds