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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
soha1902
Creator
Creator

How to Remove '-' from field


Hi All,

I have one field like below

FieldName
AB-12
CD-34
AC-BC-45
AB-AC-56
DE-10

My requirement is if  a pariticular fieldname value contains non numeric values in its 2nd position then I need to remove first '-' from left.

For example:

Values AC-BC-45

            AB-AC-56

conatins non numeric values in its 2nd position (BC and AC)

Now I want to remove first  '-' from left and the desired output should like this:

FieldName
AB-12
CD-34
ACBC-45
ABAC-56
DE-10

Please help.

Thanks.

Labels (1)
1 Solution

Accepted Solutions
stigchel
Partner - Master
Partner - Master

Try with

=PurgeChar(FieldName,'0123456789-')&'-'&KeepChar(FieldName,'0123456789')

View solution in original post

3 Replies
stigchel
Partner - Master
Partner - Master

Try with

=PurgeChar(FieldName,'0123456789-')&'-'&KeepChar(FieldName,'0123456789')

tresB
Champion III
Champion III

Try like:

Load

If(not IsNum(SubField(Input,'-',2)), SubField(Input,'-',1)&Mid(Input,Index(Input,'-',1)+1), Input) as NewInput;

Load * Inline [

Input

AB-12

CD-34

AC-BC-45

AB-AC-56

DE-10

];

awhitfield
Partner - Champion
Partner - Champion

Hi shoa,

See the example below using an inline load:

DATA:

Load (Left(Data,2)&Mid(Data,4)) AS Data
Inline
[
Data
AB-DC-01
]
;

Which gives the result ABDC-01

HTH

Andy