<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Find search string within text in script in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727098#M55416</link>
    <description>&lt;P&gt;If you don't have huge data set then use what&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/894"&gt;@Saravanan_Desingh&lt;/a&gt;&amp;nbsp; suggested. It is simple and easy to understand. Just to add on if you want the output as ';' separated then use concat(String,';') either as measure in chart or in script using group by on further load.&lt;/P&gt;</description>
    <pubDate>Sun, 12 Jul 2020 11:54:07 GMT</pubDate>
    <dc:creator>Kushal_Chawda</dc:creator>
    <dc:date>2020-07-12T11:54:07Z</dc:date>
    <item>
      <title>Find search string within text in script</title>
      <link>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727053#M55408</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I need to build the logic in script for below data scenario&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;text_description&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;search_string&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc;N:xyz;abc;N:pqr;K:123;N:123;&amp;nbsp; &amp;nbsp;N&lt;BR /&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B:abc;xyz;abc;B:123;xyz;N:123;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;BR /&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 123;C:test;C:234;abc;pqr;B:xyz;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;text_description&lt;/STRONG&gt; always starts with some texts and end with ';' and in between texts are also separated by ';'.&lt;/P&gt;&lt;P&gt;I want to search value of &lt;STRONG&gt;search_string&lt;/STRONG&gt; column in &lt;STRONG&gt;text_description&lt;/STRONG&gt; column and extract the part of string with below logic&lt;/P&gt;&lt;P&gt;Let's take a example of &lt;STRONG&gt;ID =1&lt;/STRONG&gt;&lt;BR /&gt;text_description is &lt;STRONG&gt;abc;N:xyz;abc;N:pqr;K:123;N:123;&lt;/STRONG&gt;&lt;BR /&gt;search_string is &lt;STRONG&gt;'N'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now I need to search 'N' followed by ':' in text_description and extract the text between 'N:'&amp;amp; ';'&lt;/P&gt;&lt;P&gt;'N:' could be anywhere in the string and could be repeated multiple times. Hence for each occurrence we need to extract the texts&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Output for ID=1&lt;/STRONG&gt; will be&lt;BR /&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;text_description&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc;&lt;FONT color="#FF0000"&gt;N:xyz&lt;/FONT&gt;;abc;&lt;FONT color="#FF0000"&gt;N:pqr&lt;/FONT&gt;;K:123;N:123;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xyz;pqr&lt;/P&gt;&lt;P&gt;Similar logic should work for other search string.&lt;/P&gt;&lt;P&gt;This is fake data as sample data will be difficult to share but in actual scenario format of the data will be same.&lt;/P&gt;&lt;P&gt;Any help will be really appreciated.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 00:27:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727053#M55408</guid>
      <dc:creator>Sagar_Apte</dc:creator>
      <dc:date>2020-07-12T00:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Find search string within text in script</title>
      <link>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727059#M55410</link>
      <description>&lt;P&gt;One Solution is.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;tab1:
LOAD *, TextBetween(text_description,search_string&amp;amp;':',';',IterNo()) As Word
While IterNo() &amp;lt;= SubStringCount(text_description,search_string&amp;amp;':');
LOAD * INLINE [
ID, text_description, search_string
1, abc;N:xyz;abc;N:pqr;K:123;N:123;, N
2, B:abc;xyz;abc;B:123;xyz;N:123;, B
3, 123;C:test;C:234;abc;pqr;B:xyz;, C
];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 05:04:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727059#M55410</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2020-07-12T05:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Find search string within text in script</title>
      <link>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727061#M55411</link>
      <description>&lt;P&gt;Output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="commQV39.PNG" style="width: 302px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/37321i356B25AD0D3DD691/image-size/large?v=v2&amp;amp;px=999" role="button" title="commQV39.PNG" alt="commQV39.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 05:05:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727061#M55411</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2020-07-12T05:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Find search string within text in script</title>
      <link>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727086#M55414</link>
      <description>&lt;P&gt;another approach if you don't want to increase your data using interno() and group it later just to have simple load statements&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;T1:
load ID,
    trim(text_description) as text_description,
    trim(search_string) as search_string
    SubStringCount(trim(text_description),trim(search_string)&amp;amp;':') as count_search_string
FROM Data;

Max:
Load max(count_search_string) as max_count_search_string;
Load FieldValue('count_search_string',RecNo()) as count_search_string
AutoGenerate FieldValueCount('count_search_string');

Let vMaxCountSearchString = Peek('max_count_search_string',0,'Max');

let vTextDescriptionFieldName ='text_description'; // text description field name in your data

let vSearchStringFieldName = 'search_string';  // search string field name in your data

Let vFormula1 = '(TextBetween($(vTextDescriptionFieldName),$(vSearchStringFieldName)&amp;amp;'
                 &amp;amp;chr(39)&amp;amp;':'&amp;amp;chr(39)&amp;amp;','&amp;amp;chr(39)&amp;amp;';'&amp;amp;chr(39)&amp;amp;')&amp;amp;';

for i=2 to '$(vMaxCountSearchString)'

let vFormula1 = '$(vFormula1)' &amp;amp;chr(39)&amp;amp;';'&amp;amp;chr(39)&amp;amp;'&amp;amp;TextBetween($(vTextDescriptionFieldName),
                $(vSearchStringFieldName)&amp;amp;'&amp;amp;chr(39)&amp;amp;':'&amp;amp;chr(39)&amp;amp;','&amp;amp;chr(39)&amp;amp;';'&amp;amp;chr(39)&amp;amp;',$(i))&amp;amp;';

Next

let vFormula2 = mid('$(vFormula1)',1,len('$(vFormula1)')-1)&amp;amp;')';

let vFormula = 'left('&amp;amp;'$(vFormula2)'&amp;amp;','&amp;amp;
               'len('&amp;amp;'$(vFormula2)'&amp;amp;')'&amp;amp;' - ('&amp;amp;'$(vMaxCountSearchString)'&amp;amp;'- count_search_string))';

let vFormula1 =Null();
let vFormula2 =Null();

T2:
Load *,
    $(vFormula) as String
Resident T1;

Drop Table T1;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 10:36:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727086#M55414</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-07-12T10:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Find search string within text in script</title>
      <link>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727098#M55416</link>
      <description>&lt;P&gt;If you don't have huge data set then use what&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/894"&gt;@Saravanan_Desingh&lt;/a&gt;&amp;nbsp; suggested. It is simple and easy to understand. Just to add on if you want the output as ';' separated then use concat(String,';') either as measure in chart or in script using group by on further load.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 11:54:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727098#M55416</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-07-12T11:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Find search string within text in script</title>
      <link>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727117#M55418</link>
      <description>&lt;P&gt;With Group By.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;tab1:
LOAD *, TextBetween(text_description,search_string&amp;amp;':',';',IterNo()) As Word,
		IterNo() As StrIx
While IterNo() &amp;lt;= SubStringCount(text_description,search_string&amp;amp;':');
LOAD * INLINE [
ID, text_description, search_string
1, abc;N:xyz;abc;N:pqr;K:123;N:123;, N
2, B:abc;xyz;abc;B:123;xyz;N:123;, B
3, 123;C:test;C:234;abc;pqr;B:xyz;, C
];

Left Join(tab1)
LOAD ID, Concat(Word,';',StrIx) As String
Resident tab1
Group By ID;&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 12 Jul 2020 15:50:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727117#M55418</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2020-07-12T15:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Find search string within text in script</title>
      <link>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727120#M55419</link>
      <description>&lt;P&gt;Output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="commQV40.PNG" style="width: 342px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/37331i6EAB2016EFE827FA/image-size/large?v=v2&amp;amp;px=999" role="button" title="commQV40.PNG" alt="commQV40.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 15:50:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727120#M55419</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2020-07-12T15:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find search string within text in script</title>
      <link>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727260#M55429</link>
      <description>&lt;P&gt;Thank you. Both work fine as expected&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 10:54:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-search-string-within-text-in-script/m-p/1727260#M55429</guid>
      <dc:creator>Sagar_Apte</dc:creator>
      <dc:date>2020-07-13T10:54:07Z</dc:date>
    </item>
  </channel>
</rss>

