Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Trim Field values

UGSCU-G

QUSJIE-G

when field values are like this if i want to omit the '-G' just to get

UGSCU

QUSJIE

????

1 Solution

Accepted Solutions
jsn
Honored Contributor

Re: Trim Field values

Left(FIELDNAME, index(FIELDNAME,'-',1)-1) as FIELDNAME

10 Replies
jsn
Honored Contributor

Re: Trim Field values

If you always want to remove every instance of '-G', then you can just use:

Replace(FIELDNAME, '-G', '') as FIELDNAME

Not applicable

Re: Trim Field values

sorry not to mention that there are also other values as

KSIJED-M

OQKDL-C

by using above condition replace i can eliminate -G but how about '-M' & '-C' from the field values??

jsn
Honored Contributor

Re: Trim Field values

Well, if the '-G/M/C' is always at the end of the string, it might be easier to just pick everything on the left of the first '-'. Something along these lines:

Left(FIELDNAME, index(FIELDNAME,'-',1)) as FIELDNAME

Not applicable

Re: Trim Field values

THE ABOVE EXPRESSION RETURNs the values with ending '-' as

KSIJED-

OQKDL-

UGSCU-

QUSJIE-

i tried to change the position number still the same outcome??

jsn
Honored Contributor

Re: Trim Field values

Left(FIELDNAME, index(FIELDNAME,'-',1)-1) as FIELDNAME

Not applicable

Re: Trim Field values

THANKS JOHN.

Not applicable

Re: Trim Field values

Hi

this is good

but if we have different symbols in the values

then how we use this expr

like _,-,&,#,@

this type of special characters how to remove this

all in one field values

jsn
Honored Contributor

Re: Trim Field values

If you're only looking to remove certain characters, use the function PurgeChar()

Not applicable

Re: Trim Field values

Hi

thanks

purgechar()

it give all values without symbols

but i need to trim from that special character onwords

like above exm

Left(FIELDNAME, index(FIELDNAME,'-',1)-1) as FIELDNAME

here how to use multiple symbols

Community Browser