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

Announcements
Maximize ROI with Qlik Professional Services – Expert Guidance, Faster Results: Explore Qlik Services
cancel
Showing results for 
Search instead for 
Did you mean: 
johnca
Specialist
Specialist

Search for specific strings

I need help determining if some specific strings are present in a field and return a yes if it is. I don't need them parsed out. The data looks like below with the expected inclusion or not. Numbers appear to be stored as text.

Rules are:

Numbers begin with 551 or 651 and 10 digits long.

Numbers begin with 751 or 851 or 951 and 8 digits long.

  

ValueInclude?
01/01/15 - 01/16/15no
01/27/16 - 02/23/16no
2 Wall Bracketsno
202 - 649301703 - 001 Period 07/29/16 - 08/28/16no
342-7278 163-4096 Period 06/01/16 - 07/05/16no
2016 - 2017 Renewal Feeno
8186, 8476, 8831no
1720281 & 1720291no
75100660/ 75100827yes
511977911 - 01/12/16no
4001745021 - 07/08/16no
5510002648/ 5510006394yes
5510005214/ 5510005788yes
5510006967/ 5510007038/ 5510007030yes
5510007016/5510004208yes
5510007038/ 5510007678/ 5510007364/ 5510006967/ 5510007174/ 5510007030yes
8772106120569243no
Account Number: ABC02699025no
Acct 202-649301702-001 Period 02/19/16 - 03/18/16no
Acct 500000882 Period 08/22/15 - 09/21/15no
Acct 500000882 Period 09/22/15 - 10/21/15no
Acct 85175552691 10/20/15 - 11/19/15no
Acct 8310005107651; 01/19/2016no
Acct 3000317097117834672 Period 06/22/16 - 07/21/16no
acct# 85175552691 Period 05/22/16 - 06/21/16no
Client Number 762293no
Contract# 8000011734no
Cust# 10638269no
Customer # 6000607033no
Kitchen Suppliesno
MANAGEMENT FEEno
Membership Duesno
Order Number 9000251488no
Plastic Cup Tumblerno
Project 381533800ISno
Quarterly Maintenance Service Contractno
REFERRAL FEEno
Registration Feesno
Requisition 55900024515no
75100454yes
75100660yes
75100663yes
85100002yes
85100029yes
85100042yes
5510000354yes
5510000682yes
5510001412yes
5510002529yes
5510002647yes
6510000049yes
6510000054yes
55100000354no

Thanks,

John

1 Solution

Accepted Solutions
miguelbraga
Partner - Specialist III
Partner - Specialist III

Try this:

ReplaceMap:
MAPPING LOAD * INLINE [

char replace
)
)

,
/

] (delimiter is ‘ ‘)
;

Table:      

LOAD *,

          if( (left(Value, 3) = '551' or left(Value, 3) = '651') and len(Value) = 10,

               'yes',                              // true for Numbers begin with 551 or 651 and 10 digits long

               if((left(Value, 3) = '751' or left(Value, 3) = '851' or left(Value, 3) = '951') and len(Value) = 8,

                   'yes',                          // true for Numbers begin with 751 or 851 or 951 and 8 digits long

                    'no')  as Include;

LOAD *,

          Subfield(ValueTransformed, ' ', 2) as Value;

LOAD *,
          MapSubString(‘ReplaceMap‘, Value) as ValueTransformed;
LOAD *

FROM [your database connection goes here];

View solution in original post

10 Replies
miguelbraga
Partner - Specialist III
Partner - Specialist III

Hey there,

You can do something like this:

Table:        

LOAD *,

          if(left(Value, 3) = '551' or left(Value, 3) = '651',

               if(len(Value) = 10, 'yes', 'no'),          // true for Numbers begin with 551 or 651 and 10 digits long

               if(left(Value, 3) = '751' or left(Value, 3) = '851' or left(Value, 3) = '951',

                    if(len(Value) = 8, 'yes', 'no')       // true for Numbers begin with 751 or 851 or 951 and 8 digits long

                         as Include;

LOAD *

FROM [your database connection goes here];

miguelbraga
Partner - Specialist III
Partner - Specialist III

Or simplify using this:

Table:       

LOAD *,

          if( (left(Value, 3) = '551' or left(Value, 3) = '651') and len(Value) = 10,

               'yes',                              // true for Numbers begin with 551 or 651 and 10 digits long

               if((left(Value, 3) = '751' or left(Value, 3) = '851' or left(Value, 3) = '951') and len(Value) = 8,

                   'yes',                          // true for Numbers begin with 751 or 851 or 951 and 8 digits long

                    'no')  as Include;

LOAD *

FROM [your database connection goes here];

johnca
Specialist
Specialist
Author

Thanks Miguel, you are right and that is similar to what I had, except I forgot some possible values. The desired values I'm seeking could also be preceded by another number or text a la;

Order Number 6519090101

1050 - 75100123

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

You can use below script.

Load Value,

        if(wildmatch(Left(Value,3),'551','651') and Len(Value) >=10,'Yes',

        if(wildmatch(Left(Value,3),'751','851') and Len(Value) >=8,'Yes','No')) as Include

From xyz;

Regards,

Kaushik Solanki


Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
miguelbraga
Partner - Specialist III
Partner - Specialist III

There are more than one delimiter in your case?

johnca
Specialist
Specialist
Author

Yes. The field is free-form text, so it may be just about anything. So far I've seen only dashes but could be semi-colons, slashes...

miguelbraga
Partner - Specialist III
Partner - Specialist III

Try this:

ReplaceMap:
MAPPING LOAD * INLINE [

char replace
)
)

,
/

] (delimiter is ‘ ‘)
;

Table:      

LOAD *,

          if( (left(Value, 3) = '551' or left(Value, 3) = '651') and len(Value) = 10,

               'yes',                              // true for Numbers begin with 551 or 651 and 10 digits long

               if((left(Value, 3) = '751' or left(Value, 3) = '851' or left(Value, 3) = '951') and len(Value) = 8,

                   'yes',                          // true for Numbers begin with 751 or 851 or 951 and 8 digits long

                    'no')  as Include;

LOAD *,

          Subfield(ValueTransformed, ' ', 2) as Value;

LOAD *,
          MapSubString(‘ReplaceMap‘, Value) as ValueTransformed;
LOAD *

FROM [your database connection goes here];

miguelbraga
Partner - Specialist III
Partner - Specialist III

johnca
Specialist
Specialist
Author

Thanks for the alternate view on this. I will play with this one as well.