<?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: Join table without prefix in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Join-table-without-prefix/m-p/1698633#M725379</link>
    <description>&lt;P&gt;One solution is Levenshtein Distance.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VBA Macro:
Function levenshtein( a, b )
	Dim i,j,cost,d,min1,min2,min3
	
 ' Avoid calculations where there there are empty words
	If Len( a ) = 0 Then levenshtein = Len( b &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; Exit Function
	If Len( b ) = 0 Then levenshtein = Len( a &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; Exit Function
	
 ' Array initialization	
	ReDim d( Len( a ), Len( b ) )

	For i = 0 To Len( a &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; d( i, 0 ) = i: Next
	For j = 0 To Len( b &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; d( 0, j ) = j: Next
	
 ' Actual calculation
	For i = 1 To Len( a )
		For j = 1 To Len( b )
                        If Mid(a, i, 1) = Mid(b, j, 1) Then cost = 0 Else cost = 1 End If
			
			' Since min() function is not a part of VBScript, we'll "emulate" it below
			min1 = ( d( i - 1, j ) + 1 )
			min2 = ( d( i, j - 1 ) + 1 )
			min3 = ( d( i - 1, j - 1 ) + cost )
			
			If min1 &amp;lt;= min2 And min1 &amp;lt;= min3 Then
				d( i, j ) = min1
			ElseIf min2 &amp;lt;= min1 And min2 &amp;lt;= min3 Then
				d( i, j ) = min2
			Else
				d( i, j ) = min3
			End If
		Next
	Next

	levenshtein = d( Len( a ), Len( b ) )
End Function&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Script:
Table1:
LOAD * INLINE [
ID, Company
1001, COLOR MAP CORP
1002, DENNISE PUBLISHING LTD
1003, "DSN GROUP, INC."
1004, DREAM TYPE LLC
1005, TECHNICAL SOLUTIONS (UK)
1006, INFO PRIVATE LIMITED
];

Join

Table2:
LOAD * INLINE [
Company2, City
COLOR MAP CORPORATION, London
DENNISE PUBLISHING , Delhi
"DSN GROUP, INC", Germany
DREAM TYPE , Tokyo
TECHNICAL SOLUTIONS , London
INFO PVT LTD., Paris
];

tabOut:
LOAD *, Levenshtein(Company, Company2) As LevenDist
Resident Table1;

Drop Table Table1;&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="commQV36.PNG" style="width: 969px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/32864i963F9FB11440AA39/image-size/large?v=v2&amp;amp;px=999" role="button" title="commQV36.PNG" alt="commQV36.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 04 May 2020 01:39:23 GMT</pubDate>
    <dc:creator>Saravanan_Desingh</dc:creator>
    <dc:date>2020-05-04T01:39:23Z</dc:date>
    <item>
      <title>Join table without prefix</title>
      <link>https://community.qlik.com/t5/QlikView/Join-table-without-prefix/m-p/1698575#M725378</link>
      <description>&lt;P&gt;To join both tables based on Company name, but the company name have inconsistent prefixes.&lt;/P&gt;&lt;TABLE width="241px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="130.182px"&gt;COLOR MAP &lt;FONT color="#FF0000"&gt;CORP&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="109.818px"&gt;COLOR MAP &lt;FONT color="#FF0000"&gt;CORPORATION&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 476px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/32851iF7EACF5D5B6605D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table1:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;ID, Company&lt;BR /&gt;1001, COLOR MAP CORP&lt;BR /&gt;1002, DENNISE PUBLISHING LTD&lt;BR /&gt;1003, "DSN GROUP, INC."&lt;BR /&gt;1004, DREAM TYPE LLC&lt;BR /&gt;1005, TECHNICAL SOLUTIONS (UK)&lt;BR /&gt;1006, INFO PRIVATE LIMITED&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Table2:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;Company, City&lt;BR /&gt;COLOR MAP CORPORATION, London&lt;BR /&gt;DENNISE PUBLISHING , Delhi&lt;BR /&gt;"DSN GROUP, INC", Germany&lt;BR /&gt;DREAM TYPE , Tokyo&lt;BR /&gt;TECHNICAL SOLUTIONS , London&lt;BR /&gt;INFO PVT LTD., Paris&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Join-table-without-prefix/m-p/1698575#M725378</guid>
      <dc:creator>karan_kn</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Join table without prefix</title>
      <link>https://community.qlik.com/t5/QlikView/Join-table-without-prefix/m-p/1698633#M725379</link>
      <description>&lt;P&gt;One solution is Levenshtein Distance.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VBA Macro:
Function levenshtein( a, b )
	Dim i,j,cost,d,min1,min2,min3
	
 ' Avoid calculations where there there are empty words
	If Len( a ) = 0 Then levenshtein = Len( b &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; Exit Function
	If Len( b ) = 0 Then levenshtein = Len( a &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; Exit Function
	
 ' Array initialization	
	ReDim d( Len( a ), Len( b ) )

	For i = 0 To Len( a &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; d( i, 0 ) = i: Next
	For j = 0 To Len( b &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; d( 0, j ) = j: Next
	
 ' Actual calculation
	For i = 1 To Len( a )
		For j = 1 To Len( b )
                        If Mid(a, i, 1) = Mid(b, j, 1) Then cost = 0 Else cost = 1 End If
			
			' Since min() function is not a part of VBScript, we'll "emulate" it below
			min1 = ( d( i - 1, j ) + 1 )
			min2 = ( d( i, j - 1 ) + 1 )
			min3 = ( d( i - 1, j - 1 ) + cost )
			
			If min1 &amp;lt;= min2 And min1 &amp;lt;= min3 Then
				d( i, j ) = min1
			ElseIf min2 &amp;lt;= min1 And min2 &amp;lt;= min3 Then
				d( i, j ) = min2
			Else
				d( i, j ) = min3
			End If
		Next
	Next

	levenshtein = d( Len( a ), Len( b ) )
End Function&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Script:
Table1:
LOAD * INLINE [
ID, Company
1001, COLOR MAP CORP
1002, DENNISE PUBLISHING LTD
1003, "DSN GROUP, INC."
1004, DREAM TYPE LLC
1005, TECHNICAL SOLUTIONS (UK)
1006, INFO PRIVATE LIMITED
];

Join

Table2:
LOAD * INLINE [
Company2, City
COLOR MAP CORPORATION, London
DENNISE PUBLISHING , Delhi
"DSN GROUP, INC", Germany
DREAM TYPE , Tokyo
TECHNICAL SOLUTIONS , London
INFO PVT LTD., Paris
];

tabOut:
LOAD *, Levenshtein(Company, Company2) As LevenDist
Resident Table1;

Drop Table Table1;&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="commQV36.PNG" style="width: 969px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/32864i963F9FB11440AA39/image-size/large?v=v2&amp;amp;px=999" role="button" title="commQV36.PNG" alt="commQV36.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 01:39:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Join-table-without-prefix/m-p/1698633#M725379</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2020-05-04T01:39:23Z</dc:date>
    </item>
  </channel>
</rss>

