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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
aki_martiskaine
Partner - Contributor II
Partner - Contributor II

If statement in a String

Hello

First time posting and I hope it's in the correct section. Please feel free to move if necessary.

I'm completing the exercises in the Qlik continuous classroom and I came across a step in a certain exercise that I don't understand.

Learning module: Business Analyst > Create Visualizations > Introduction to String Functions

One step in this exercise is to use the following string in a new dimension in order to organize data by region in a Filter Pane.

If(Right(Region,7)='America','Americas','EMEA')

In the Filter Pane there is a dimension "Region" which contains the following values: "Europe", "North America" or "South America"

While the string is working great and returns values North America -> Americas, South America -> Americas, Europe -> EMEA in the new dimension, I'm frustrated because I can't understand how it actually works. I tried looking for similar problems with If statement combined with string function Right but no luck.

1 Solution

Accepted Solutions
giakoum
Partner - Master II
Partner - Master II

Right reads 7 characters from the end of the Region string (from the right). If these 7 characters read America, the if statement returns Americas otherwise it returns EMEA.

There is also Left and Mid that do similar. See help

View solution in original post

4 Replies
giakoum
Partner - Master II
Partner - Master II

Right reads 7 characters from the end of the Region string (from the right). If these 7 characters read America, the if statement returns Americas otherwise it returns EMEA.

There is also Left and Mid that do similar. See help

sunny_talwar

Are you not sure about the Right function or is there anything else you are not sure about?

agigliotti
Partner - Champion
Partner - Champion

it's works as expected.

take a look here Right - script and chart function ‒ QlikView

it's just another field created on the fly.

you also do the same in script as below:

LOAD

...

...

If(Right(Region,7)='America','Americas','EMEA') as NewRegion


and use this new field as your chart dimension.

aki_martiskaine
Partner - Contributor II
Partner - Contributor II
Author

Hey and thanks for everyone's replies. As they are all correct I will mark the first one, it also being most easy to understand.

Ok so If(Right(Region,7)='America','Americas','EMEA') is just an 'if' statement. I was looking at it wrong because I was driven off by the use of 'Right' string in it.


So this is how I now understand it: If (the string of last 7 = "America") then ("Americas") else ("EMEA").