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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Replace only first space to a underscore in expression

Hi,

Replace only first space to a underscore in expression

this is urgent please reply

1 Solution

Accepted Solutions
robert_mika
Master III
Master III

I just added pictures but

You have got 3 part

the first mid takes all characters up to first space--   mid('mam ko ll  --',1,index('mam ko ll  --',' ')-1)

then you add underscore ----->  &'_'&

and the second mid will add the rest of the string -> mid('mam ko ll  --',index('mam ko ll  --',' ')+1,len('mam ko ll  --'))

View solution in original post

11 Replies
Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Try this

=Replace('AB CDEFG',' ' ,'_')

The AB CDEFG could be filed name

robert_mika
Master III
Master III

2015-04-08 00_59_26-Text Object Properties [mam _ko ll  --].png

=mid('mam ko ll  --',1,index('mam ko ll  --',' ')-1)&'_'&mid('mam ko ll  --',index('mam ko ll  --',' ')+1,len('mam ko ll  --'))

Not applicable
Author

Hi,

the String has more than one spaces but want to replace only the first one.

example:

'ab cd ef gh'

output required

'ab_cd ef gh'

Not applicable
Author

can you please expalin this

robert_mika
Master III
Master III

I just added pictures but

You have got 3 part

the first mid takes all characters up to first space--   mid('mam ko ll  --',1,index('mam ko ll  --',' ')-1)

then you add underscore ----->  &'_'&

and the second mid will add the rest of the string -> mid('mam ko ll  --',index('mam ko ll  --',' ')+1,len('mam ko ll  --'))

robert_mika
Master III
Master III

Another way

=TextBetween('mam ko ll  --','',' ',1)&'_'&TextBetween('mam ko ll  --',' ','',1)

Anonymous
Not applicable
Author

I hope it is simpler:

=subfield('ab cd ef gh', ' ',1) & '_' & mid('ab cd ef gh', len(subfield('ab cd ef gh', ' ',1))+1)

Not applicable
Author

can you please tell me the same for the third Space.

Not applicable
Author

can you please tell me the same for the third Space.