Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
sanjujeeboy
New Contributor II

extract string

i have 2 field values

sales_mrtyf_qtr_09_2017

under_qtr_03_2015

i want to extract the string 'qtr'  from both values. how to achieve that?

1 Solution

Accepted Solutions
Highlighted
sunilkumarqv
Valued Contributor II

Re: extract string

This will work for

if(WildMatch(YourField,'*qtr*'),'Qtr')

View solution in original post

12 Replies
MVP
MVP

Re: extract string

It's 3rd subfield (delimited by '_') from end.

try like:

=SubField(YourField,'_', - 3 )

sanjujeeboy
New Contributor II

Re: extract string

the end is not specific....after 2017 there can be values like 2017_abc etc..

shwethaa
New Contributor III

Re: extract string

Try this-

=mid('sales_mrtyf_qtr_09_2017',index('sales_mrtyf_qtr_09_2017','qtr',1),3)

Mid(text,index(text,searchstring,1),3)

arvind1494
Valued Contributor

Re: extract string

Try this

left(Right('sales_mrtyf_qtr_09_2017',11),3)

left(Right('under_qtr_03_2015',11),3)

Highlighted
sunilkumarqv
Valued Contributor II

Re: extract string

This will work for

if(WildMatch(YourField,'*qtr*'),'Qtr')

View solution in original post

shwethaa
New Contributor III

Re: extract string

I don't think this solution will work because we can't predict that qtr will be in same position. So it is not flexible with different data right?

Partner
Partner

Re: extract string

Hi Jeeyboy

try this

replace(PurgeChar ( Replace('sales_mrtyf_qtr_09_2017','_qtr_','$'),

'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'),'$','_qtr_')

Regards

Raman Rastogi

vishsaggi
Esteemed Contributor III

Re: extract string

Try this?

= Mid(TextFieldnamehere, Index(YourTextFieldnamehere, 'qtr'), 3)

sanjujeeboy
New Contributor II

Re: extract string

yes you are right.....the wildmatch solution given above is working fine.....