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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Find first letter in values

Hi, my datasource has one column where the values look like this:

1 061,020 M3

2 645,016 MWH

The field value contains both numeric and text data, and I need to get rid of the unit on the right side of the field. I want the result to be:

1061,020

2645,016

The problem is that the unit can be like the example above ' M3', which also contains a numeric value. Since I always have three decimals I tried to combine floor() and purgechar(ABC.....) to get rid of the letters and round down to three decimals, but unfortunately that failed. The best way, as I see it, would be to find the first letter and then skip everything from there but I don´t know if thats possible. Any suggestions?

MVH

Johan

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

You could use

     Left(Field, Index(Field, Left(Keepchar(Field,'ABC...'),1))-1)

I.e. the ABC... should list all characters. The Left function returns the first character and the Index function returns its position.

HIC

View solution in original post

4 Replies
nilesh_gangurde
Partner - Specialist
Partner - Specialist

You can use the Left Function to achieve the same.

left( s , n )

Substring of the string s. The result is a string consisting of the first n characters of s.

Example:

left('abcdef',3) returns 'abc'.

left(Date, 4) where Date = 1997-07-14 returns 1997.

-Nilesh

Anonymous
Not applicable
Author

Johan,

Is there always a space between the groups?  If yes, you can use this:

subfield(<your field>, ' ', 1)

Regards,

Michael

Edit: didn't notice there were two spaces.  Fixing:

subfield(<your field>, ' ', 1) & subfield(<your field>, ' ', 2)

hic
Former Employee
Former Employee

You could use

     Left(Field, Index(Field, Left(Keepchar(Field,'ABC...'),1))-1)

I.e. the ABC... should list all characters. The Left function returns the first character and the Index function returns its position.

HIC

Anonymous
Not applicable
Author

Works perfekt, thanks