<?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: Add value to table if string match from ohter table in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Add-value-to-table-if-string-match-from-ohter-table/m-p/1796724#M1211326</link>
    <description>&lt;P&gt;Try the script below (replacing the initial inline loads with your Excel file loads).&amp;nbsp; There might be a way to reduce the steps if you work directly in the main Data table, but I wanted to isolate the process assigning Categorie to Text before adding it to the main data.&lt;/P&gt;&lt;P&gt;Categorie:&lt;BR /&gt;Load * inline [&lt;BR /&gt;Categorie, Text&lt;BR /&gt;Cat1,Testtext1&lt;BR /&gt;Cat2,Testtext2&lt;BR /&gt;Cat3,Testtext3&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Data:&lt;BR /&gt;Load * inline [&lt;BR /&gt;Col1,Col2,Col3,ColumnX&lt;BR /&gt;A,B,C,text1&lt;BR /&gt;D,E,F,text2&lt;BR /&gt;G,H,I,nothing&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;//Load unique ColumnX values in TempTable&lt;BR /&gt;TempTable:&lt;BR /&gt;Load distinct ColumnX&lt;BR /&gt;Resident Data;&lt;/P&gt;&lt;P&gt;//Create a row for each Text value / Categorie value combination&lt;BR /&gt;Join (TempTable)&lt;BR /&gt;Load Text,&lt;BR /&gt;Categorie&lt;BR /&gt;Resident Categorie;&lt;/P&gt;&lt;P&gt;//Limit rows to only rows where ColumnX is contained in Text&lt;BR /&gt;TempTable2:&lt;BR /&gt;Load Distinct ColumnX,&lt;BR /&gt;Categorie&lt;BR /&gt;Resident TempTable&lt;BR /&gt;where wildmatch(Text,'*'&amp;amp;ColumnX&amp;amp;'*');&lt;/P&gt;&lt;P&gt;drop table TempTable;&lt;/P&gt;&lt;P&gt;//Reload TempTable with All unique ColumnX values&lt;BR /&gt;TempTable:&lt;BR /&gt;Load distinct ColumnX&lt;BR /&gt;Resident Data;&lt;/P&gt;&lt;P&gt;//Add Categorie derived in TempTable2 to TempTable&lt;BR /&gt;Join (TempTable)&lt;BR /&gt;Load ColumnX,&lt;BR /&gt;Categorie as CategorieTemp&lt;BR /&gt;Resident TempTable2;&lt;/P&gt;&lt;P&gt;//Replace Null values with 'Other'&lt;BR /&gt;Join (TempTable)&lt;BR /&gt;Load ColumnX,&lt;BR /&gt;if(IsNull(CategorieTemp),'Other',CategorieTemp) as Categorie&lt;BR /&gt;Resident TempTable;&lt;/P&gt;&lt;P&gt;//Join Catagorie to Data table&lt;BR /&gt;Join (Data)&lt;BR /&gt;Load ColumnX,&lt;BR /&gt;Categorie&lt;BR /&gt;Resident TempTable;&lt;/P&gt;&lt;P&gt;drop table TempTable, TempTable2, Categorie;&lt;/P&gt;</description>
    <pubDate>Sat, 03 Apr 2021 20:10:48 GMT</pubDate>
    <dc:creator>GaryGiles</dc:creator>
    <dc:date>2021-04-03T20:10:48Z</dc:date>
    <item>
      <title>Add value to table if string match from ohter table</title>
      <link>https://community.qlik.com/t5/QlikView/Add-value-to-table-if-string-match-from-ohter-table/m-p/1796722#M1211325</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one table in an excel file (C:\cat.xlsx) with categories which looks like this&lt;/P&gt;&lt;P&gt;Categorie, Text&lt;BR /&gt;Cat1,Testtext1&lt;BR /&gt;Cat2,Testtext2&lt;BR /&gt;Cat3,Testtext3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Than i have a main CSV file (C:\main.csv) which has some columns, and if the value in ColumnX is part of any value of the "Text" column than add the according "Categorie" instead.&lt;/P&gt;&lt;P&gt;Pseudocode look like this:&lt;/P&gt;&lt;P&gt;Load Col1, Col2, Col3, ColumnX,&lt;/P&gt;&lt;P&gt;if ("ColumnX" part of any of "Text" from Categories) THEN add CatX as Main_Cat&lt;/P&gt;&lt;P&gt;ELSE add OTHER as Main_Cat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;Excel File looks like this&lt;/P&gt;&lt;P&gt;Col1,Col2,Col3,ColumnX&lt;/P&gt;&lt;P&gt;A,B,C,text1&lt;BR /&gt;D,E,F,text2&lt;BR /&gt;G,H,I,nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Qlik it should than look like this:&lt;/P&gt;&lt;P&gt;Col1,Col2,Col3,ColumnX,Main_Cat&lt;/P&gt;&lt;P&gt;A,B,C,text1,Cat1&lt;BR /&gt;D,E,F,text2,Cat2&lt;BR /&gt;G,H,I,nothing,OTHER&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i do that in the LOAD statement?&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 15:59:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Add-value-to-table-if-string-match-from-ohter-table/m-p/1796722#M1211325</guid>
      <dc:creator>CehKay</dc:creator>
      <dc:date>2021-04-03T15:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Add value to table if string match from ohter table</title>
      <link>https://community.qlik.com/t5/QlikView/Add-value-to-table-if-string-match-from-ohter-table/m-p/1796724#M1211326</link>
      <description>&lt;P&gt;Try the script below (replacing the initial inline loads with your Excel file loads).&amp;nbsp; There might be a way to reduce the steps if you work directly in the main Data table, but I wanted to isolate the process assigning Categorie to Text before adding it to the main data.&lt;/P&gt;&lt;P&gt;Categorie:&lt;BR /&gt;Load * inline [&lt;BR /&gt;Categorie, Text&lt;BR /&gt;Cat1,Testtext1&lt;BR /&gt;Cat2,Testtext2&lt;BR /&gt;Cat3,Testtext3&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Data:&lt;BR /&gt;Load * inline [&lt;BR /&gt;Col1,Col2,Col3,ColumnX&lt;BR /&gt;A,B,C,text1&lt;BR /&gt;D,E,F,text2&lt;BR /&gt;G,H,I,nothing&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;//Load unique ColumnX values in TempTable&lt;BR /&gt;TempTable:&lt;BR /&gt;Load distinct ColumnX&lt;BR /&gt;Resident Data;&lt;/P&gt;&lt;P&gt;//Create a row for each Text value / Categorie value combination&lt;BR /&gt;Join (TempTable)&lt;BR /&gt;Load Text,&lt;BR /&gt;Categorie&lt;BR /&gt;Resident Categorie;&lt;/P&gt;&lt;P&gt;//Limit rows to only rows where ColumnX is contained in Text&lt;BR /&gt;TempTable2:&lt;BR /&gt;Load Distinct ColumnX,&lt;BR /&gt;Categorie&lt;BR /&gt;Resident TempTable&lt;BR /&gt;where wildmatch(Text,'*'&amp;amp;ColumnX&amp;amp;'*');&lt;/P&gt;&lt;P&gt;drop table TempTable;&lt;/P&gt;&lt;P&gt;//Reload TempTable with All unique ColumnX values&lt;BR /&gt;TempTable:&lt;BR /&gt;Load distinct ColumnX&lt;BR /&gt;Resident Data;&lt;/P&gt;&lt;P&gt;//Add Categorie derived in TempTable2 to TempTable&lt;BR /&gt;Join (TempTable)&lt;BR /&gt;Load ColumnX,&lt;BR /&gt;Categorie as CategorieTemp&lt;BR /&gt;Resident TempTable2;&lt;/P&gt;&lt;P&gt;//Replace Null values with 'Other'&lt;BR /&gt;Join (TempTable)&lt;BR /&gt;Load ColumnX,&lt;BR /&gt;if(IsNull(CategorieTemp),'Other',CategorieTemp) as Categorie&lt;BR /&gt;Resident TempTable;&lt;/P&gt;&lt;P&gt;//Join Catagorie to Data table&lt;BR /&gt;Join (Data)&lt;BR /&gt;Load ColumnX,&lt;BR /&gt;Categorie&lt;BR /&gt;Resident TempTable;&lt;/P&gt;&lt;P&gt;drop table TempTable, TempTable2, Categorie;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 20:10:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Add-value-to-table-if-string-match-from-ohter-table/m-p/1796724#M1211326</guid>
      <dc:creator>GaryGiles</dc:creator>
      <dc:date>2021-04-03T20:10:48Z</dc:date>
    </item>
  </channel>
</rss>

