Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anuhyak1
Creator
Creator

Add to place character - after first 5 digits of a field

a) I have  a style field in database. I need to place  -  after 1st five digits or characters. 

Actual Style Expected Style
1EA45EMN51EA45-EMN5
2BA45MNP62BA45-MNP6
8cde1HJK2C8cde1-HJK2C

 

1 Solution

Accepted Solutions
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

In case you have more digits in the field:

Value:

load Actual,index(Actual,5)as Index,left(Actual,5)&'-'&right(Actual,len(Actual)-5) as Expected inline [
Actual
1EA45EMN5
2BA45MNP6
8cde1HJK2C
aaaaaaaaaaa
];

View solution in original post

5 Replies
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Try this:

Value:
load Actual,left(Actual,5)&'-'&right(Actual,5) as Expected inline [
Actual
1EA45EMN5
2BA45MNP6
8cde1HJK2C
];

Arthur_Fong
Partner - Specialist III
Partner - Specialist III

In case you have more digits in the field:

Value:

load Actual,index(Actual,5)as Index,left(Actual,5)&'-'&right(Actual,len(Actual)-5) as Expected inline [
Actual
1EA45EMN5
2BA45MNP6
8cde1HJK2C
aaaaaaaaaaa
];

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

or maybe just 

mid(Actual, 6) for the right-hand side.

-Rob

Anuhyak1
Creator
Creator
Author

Thanks for the reply. But, In the style field  We are getting 12 characters some times in style field  and 8 characters  . In that case some characters are truncating if you hard code. I just need '- 'after 5 characters from left. 

I have used below expr in chart 

=left(STYLE,4)&'-'& right(STYLE,5)

STYLE  
P3SoQt4368P3so-t4368Q is truncating
BETR5678BETR-5678correct 

 

 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

=left(STYLE,4)&'-'& mid(STYLE,5)

-Rob