<?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: Applying Filter Using VBScript in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512307#M600107</link>
    <description>&lt;P&gt;You might round the number with something like int() or you could use replace() to replace the comma with a dot.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
    <pubDate>Mon, 26 Nov 2018 14:12:04 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2018-11-26T14:12:04Z</dc:date>
    <item>
      <title>Applying Filter Using VBScript</title>
      <link>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512199#M600102</link>
      <description>&lt;PRE&gt;sub ApplyDistanceFilter

	vdf = getVariableString("varDistanceFrom")
	vdfield =getVariableString("varDistanceFromSiteField")
	vdi = getVariableString("varDistanceInside")
	
	IF vdi = 1 Then	'	Inside
		 ActiveDocument.Fields(vdfield).Select " &amp;lt;" &amp;amp; vdf
	ELSE			' Outside
		 ActiveDocument.Fields(vdfield).Select " &amp;gt;" &amp;amp; vdf
	END IF
end sub&lt;/PRE&gt;&lt;P&gt;GetVariableString Function&lt;/P&gt;&lt;PRE&gt;function getVariableString(varName)
	set v = ActiveDocument.Variables(varName)
	getVariableString = v.GetContent.String
end function&lt;/PRE&gt;&lt;P&gt;Trying to apply a filter via VBScript using the above.&lt;/P&gt;&lt;P&gt;The script has a few variables...&lt;/P&gt;&lt;P&gt;vdf =&amp;nbsp;Distance from site - numeric (populated using a slicer&lt;BR /&gt;vdfield =&amp;nbsp;Field I want to filter on - there are four possibles (we have four sites)&lt;BR /&gt;vdi =&amp;nbsp;Inside (1) or Outside (0) cvf&lt;/P&gt;&lt;P&gt;I cannot get this to work - hoping it is just syntax somewhere.&lt;/P&gt;&lt;P&gt;Any assistance greatly appreciated.&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 12:44:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512199#M600102</guid>
      <dc:creator>pkelly</dc:creator>
      <dc:date>2018-11-26T12:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Filter Using VBScript</title>
      <link>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512260#M600103</link>
      <description>&lt;P&gt;Maybe it doesn't like the set-statement within the function - just try it with:&lt;/P&gt;&lt;PRE&gt;function getVariableString(varName)
	getVariableString = ActiveDocument.Variables(varName).GetContent.String
end function&lt;/PRE&gt;&lt;P&gt;and reading the variable-value in this way I would probably not use an extra function for it.&lt;/P&gt;&lt;P&gt;Beside this I'm not sure if I would use a macro at all because it (the direct selection of fieldvalues) could also be implemented with actions - and it might be also an alternatively not to select anything else to use these variables (or maybe fieldvalues from an island-table) within set analysis expressions.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 13:25:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512260#M600103</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-11-26T13:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Filter Using VBScript</title>
      <link>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512277#M600104</link>
      <description>&lt;P&gt;Thanks Marcus - already have this working with Set Analysis...&lt;/P&gt;&lt;PRE&gt;=IF(varDistanceFromSite = 'None', SUM(sin_Sales),

	IF(varDistanceFromSite = 'Glasgow' AND varDistanceInside = 1, SUM({&amp;lt;cst_MilesFromGlasgow = {"&amp;lt;= $(varDistanceFrom)"} &amp;gt;} sin_Sales),
	IF(varDistanceFromSite = 'Glasgow' AND varDistanceInside = 0, SUM({&amp;lt;cst_MilesFromGlasgow = {"&amp;gt;= $(varDistanceFrom)"} &amp;gt;} sin_Sales),
		
	IF(varDistanceFromSite = 'Poole' AND varDistanceInside = 1, SUM({&amp;lt;cst_MilesFromPoole = {"&amp;lt;= $(varDistanceFrom)"} &amp;gt;} sin_Sales),
	IF(varDistanceFromSite = 'Poole' AND varDistanceInside = 0, SUM({&amp;lt;cst_MilesFromPoole = {"&amp;gt;= $(varDistanceFrom)"} &amp;gt;} sin_Sales),
		
	IF(varDistanceFromSite = 'SDC' AND varDistanceInside = 1, SUM({&amp;lt;cst_MilesFromSDC = {"&amp;lt;= $(varDistanceFrom)"} &amp;gt;} sin_Sales),
	IF(varDistanceFromSite = 'SDC' AND varDistanceInside = 0, SUM({&amp;lt;cst_MilesFromSDC = {"&amp;gt;= $(varDistanceFrom)"} &amp;gt;} sin_Sales),
		
	IF(varDistanceFromSite = 'Stonehouse' AND varDistanceInside = 1, SUM({&amp;lt;cst_MilesFromStonehouse = {"&amp;lt;= $(varDistanceFrom)"} &amp;gt;} sin_Sales),
	IF(varDistanceFromSite = 'Stonehouse' AND varDistanceInside = 0, SUM({&amp;lt;cst_MilesFromStonehouse = {"&amp;gt;= $(varDistanceFrom)"} &amp;gt;} sin_Sales))))))))))&lt;/PRE&gt;&lt;P&gt;Issue I have is that I am displaying data on a Bullet Chart with a Map of the UK and it is very clunky.&lt;/P&gt;&lt;P&gt;The map does not zoom in so thought I could get round this with filtering.&lt;/P&gt;&lt;P&gt;The change you have suggested are having an impact - the map is filtering but as soon as I try to apply &amp;lt; or &amp;gt; nothing happens..&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;If vdi = 1 Then	'	Inside
		ActiveDocument.Fields(vdfield).Select " &amp;lt;" &amp;amp; vdf
Else			' Outside
		ActiveDocument.Fields(vdfield).Select " &amp;gt;" &amp;amp; vdf
End If&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 13:39:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512277#M600104</guid>
      <dc:creator>pkelly</dc:creator>
      <dc:date>2018-11-26T13:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Filter Using VBScript</title>
      <link>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512294#M600105</link>
      <description>&lt;P&gt;A selection with &amp;lt; or &amp;gt; worked usually well by a numerical field. This means that either your field isn't numeric or your vdf variable isn't treated as a number, for example if it contained a formatting like a comma as thousand- or decimal delimiter.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 13:53:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512294#M600105</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-11-26T13:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Filter Using VBScript</title>
      <link>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512305#M600106</link>
      <description>&lt;P&gt;There is a decimal delimiter - distances are to 1dp.&lt;/P&gt;&lt;P&gt;How do I get round this?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 14:05:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512305#M600106</guid>
      <dc:creator>pkelly</dc:creator>
      <dc:date>2018-11-26T14:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Filter Using VBScript</title>
      <link>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512307#M600107</link>
      <description>&lt;P&gt;You might round the number with something like int() or you could use replace() to replace the comma with a dot.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 14:12:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512307#M600107</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-11-26T14:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Filter Using VBScript</title>
      <link>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512315#M600108</link>
      <description>&lt;P&gt;Thanks for all your help so far...&lt;/P&gt;&lt;PRE&gt;If vdi = 1 then	'	Inside
	ActiveDocument.Fields(vdfield).select vdf
Else			' Outside
	ActiveDocument.Fields(vdfield).select  vdf
End If&lt;/PRE&gt;&lt;P&gt;If I use the above with my slider set to 50, it works as I have a customer(s) exactly 50 miles away.&lt;/P&gt;&lt;P&gt;Also changed the slider as I have a customer who is 11.5 miles away and it filtered okay on 11.5.&lt;/P&gt;&lt;P&gt;This suggests to me that the number format is okay.&lt;/P&gt;&lt;P&gt;Therefore, I think it is syntax..have tried...&lt;/P&gt;&lt;PRE&gt;If vdi = 1 then	'	Inside
	ActiveDocument.Fields(vdfield).select &amp;lt; vdf
Else			' Outside
	ActiveDocument.Fields(vdfield).select  &amp;gt; vdf
End If&lt;/PRE&gt;&lt;P&gt;And...&lt;/P&gt;&lt;PRE&gt;If vdi = 1 then	'	Inside
	ActiveDocument.Fields(vdfield).select " &amp;lt;" &amp;amp; vdf
Else			' Outside
	ActiveDocument.Fields(vdfield).select  " &amp;gt;" &amp;amp; vdf
End If&lt;/PRE&gt;&lt;P&gt;With no success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 14:22:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512315#M600108</guid>
      <dc:creator>pkelly</dc:creator>
      <dc:date>2018-11-26T14:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Filter Using VBScript</title>
      <link>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512323#M600109</link>
      <description>&lt;P&gt;Got it...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;If vdi = 1 then	'	Inside
	ActiveDocument.Fields(vdfield).select "&amp;lt;" &amp;amp; vdf
Else			' Outside
	ActiveDocument.Fields(vdfield).select  "&amp;gt;" &amp;amp; vdf
End If&lt;/PRE&gt;&lt;P&gt;The ApiGuide had a space before &amp;lt; and &amp;gt;.&lt;/P&gt;&lt;P&gt;Took that out and it works.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 14:30:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Applying-Filter-Using-VBScript/m-p/1512323#M600109</guid>
      <dc:creator>pkelly</dc:creator>
      <dc:date>2018-11-26T14:30:20Z</dc:date>
    </item>
  </channel>
</rss>

