Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Cannot output all data when using left & index

Hi,

I have a list of names of which some contain (

I am using the code below to take the values prior to the ( which works great.

left(a.name, index(a.name,'(') -1) as [Name]

However, the values without any ( aren't returned.  What's the best way to add them in?

Thanks,

Gwyn

1 Solution

Accepted Solutions
Not applicable
Author

Hello Gwyn,

you should use an if()-statement similar to this:

Load . . .

If( index(a.name,'(')) > 0, left(a.name, index(a.name,'(') -1), a.name) AS Name,

. . .

Regards, Roland

View solution in original post

6 Replies
Not applicable
Author

Hello Gwyn,

you should use an if()-statement similar to this:

Load . . .

If( index(a.name,'(')) > 0, left(a.name, index(a.name,'(') -1), a.name) AS Name,

. . .

Regards, Roland

perumal_41
Partner - Specialist II
Partner - Specialist II

please upload ur file

nagaiank
Specialist III
Specialist III

Try the following script, it works for me.

SubField(a.Name,'(',1) as Name

Not applicable
Author

Cheers Ronald, works great

Not applicable
Author

Krishnamoorthy, also works great.

For some reason, I couldn't mark yours as correct as well.  Maybe as I'd already marked Ronald's as correct. 

Sorry!

erichshiino
Partner - Master
Partner - Master

You can try to use subfield instead of your expression:

=SubField(a.name, '(', 1)

It will return everything if it doesn't find the bracket

Regards,

Erich