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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Alarkis
Contributor III
Contributor III

Splitting and adding String to Integer(Date)

Hello,

I have a field : (Years + Quarter)

Alarkis_0-1601802155025.png

I have 2 questions:

1)how can I add a string in the middle of an integer

Example :(2018 3) to (2018 Q3).

2) How can i split the field to 2 parts

Example: (2018 3) to Year:(2018)    Quarter:(3)

 

Labels (2)
2 Solutions

Accepted Solutions
Taoufiq_Zarra
MVP
MVP

@Alarkis 

for question 1 :

left(Field,4)&' Q'&right(Field,1)

 

for question2:

 'Year:('&left(Field,4)&') Quarter:('&right(Field,1)&')'

 

for example :

Data:

load *, left(Field,4)&' Q'&right(Field,1) as Question1, 'Year:('&left(Field,4)&') Quarter:('&right(Field,1)&')' as Question2 inline [
Field
2018 1
2018 2
2018 3
2018 4
];

ouput:

Capture.PNG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

Taoufiq_Zarra
MVP
MVP

@Alarkis  like ?

 'Year:('&left(Field,4)&')' 

and for quarter

'Quarter:('&right(Field,1)&')'

example :

Data:

load *, left(Field,4)&' Q'&right(Field,1) as Question1, 'Year:('&left(Field,4)&')' as Year, 'Quarter:('&right(Field,1)&')' as Quarter inline [
Field
2018 1
2018 2
2018 3
2018 4
];

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

3 Replies
Taoufiq_Zarra
MVP
MVP

@Alarkis 

for question 1 :

left(Field,4)&' Q'&right(Field,1)

 

for question2:

 'Year:('&left(Field,4)&') Quarter:('&right(Field,1)&')'

 

for example :

Data:

load *, left(Field,4)&' Q'&right(Field,1) as Question1, 'Year:('&left(Field,4)&') Quarter:('&right(Field,1)&')' as Question2 inline [
Field
2018 1
2018 2
2018 3
2018 4
];

ouput:

Capture.PNG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Alarkis
Contributor III
Contributor III
Author

Thanks for the reply.

For question 2 i mean Year is separate field and Quarter is separate field

Taoufiq_Zarra
MVP
MVP

@Alarkis  like ?

 'Year:('&left(Field,4)&')' 

and for quarter

'Quarter:('&right(Field,1)&')'

example :

Data:

load *, left(Field,4)&' Q'&right(Field,1) as Question1, 'Year:('&left(Field,4)&')' as Year, 'Quarter:('&right(Field,1)&')' as Quarter inline [
Field
2018 1
2018 2
2018 3
2018 4
];

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉