<?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: How to pass multiple values from filter to a SQL query in data load script? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157479#M93774</link>
    <description>&lt;P&gt;It depends mainly on the from the data-base supported syntax. I suggest you comment the month-variable at first and writes two month manually within the in() or in "...." or whatever the data-base recognized. If it worked you shows the variable-content within a text-box until it looked like your hard-coded values.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jan 2024 14:11:47 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2024-01-02T14:11:47Z</dc:date>
    <item>
      <title>How to pass multiple values from filter to a SQL query in data load script?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2156892#M93726</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have the following requirement:&lt;/P&gt;
&lt;P&gt;1.User selects Year (single value) and Month (multiple values) from the filters in a sheet&lt;/P&gt;
&lt;P&gt;2.User clicks on Reload button (Button Chart Type), which then passes the values to the Data Load scripts&lt;/P&gt;
&lt;P&gt;3.The SQL query in Data Load script has 'Year' and 'Month' in the WHERE condition and single/multiple values needs to be passed. I guess it would be something like this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SELECT COUNT(OrderID) NoOfOrders, SUM(OrderAmount) OrderAmount&lt;BR /&gt;FROM Orders&lt;BR /&gt;WHERE TO_CHAR(OrderDate,'YYYY') = '$(vYearID)'&lt;BR /&gt;AND&amp;nbsp;TO_CHAR(OrderDate,'MM') IN '$(vMonthID)'&lt;/P&gt;
&lt;P&gt;Would the IN condition work in the SQL query, if the vMonthID is populated as 9,10,11?&lt;/P&gt;
&lt;P&gt;Can someone please share the steps or a sample file for reference?&lt;/P&gt;
&lt;P&gt;Many 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;</description>
      <pubDate>Fri, 29 Dec 2023 15:30:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2156892#M93726</guid>
      <dc:creator>satya_s</dc:creator>
      <dc:date>2023-12-29T15:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from filter to a SQL query in data load script?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2156907#M93729</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please note that I am able to refresh the data in the SQL when there is only 1 value in the variables &lt;STRONG&gt;vYear&lt;/STRONG&gt; and &lt;STRONG&gt;vMonth&lt;/STRONG&gt; variables. The following works...&lt;/P&gt;
&lt;P&gt;vYear = GetFieldSelections(YearID);&lt;BR /&gt;vMonth = GetFieldSelections(MonthID);&lt;BR /&gt;The above variables are set in the Reload button configuration under 'Actions and Navigation'.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="satya_s_0-1703876798485.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/126277iA5FA88A2CF413C60/image-size/medium?v=v2&amp;amp;px=400" role="button" title="satya_s_0-1703876798485.png" alt="satya_s_0-1703876798485.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SELECT COUNT(OrderID) NoOfOrders, SUM(OrderAmount) OrderAmount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM Orders&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WHERE TO_CHAR(OrderDate,'YYYY') = $(vYear)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AND&amp;nbsp;TO_CHAR(OrderDate,'MM') &lt;STRONG&gt;=&lt;/STRONG&gt; $(vMonth)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The &lt;STRONG&gt;issue&lt;/STRONG&gt; comes when there are &lt;STRONG&gt;multiple&lt;/STRONG&gt; values selected from the filter. For example if I select Months 9,10 and 11 from the filter then the SQL query fails on click of Reload button because the IN condition doesn't work.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SELECT COUNT(OrderID) NoOfOrders, SUM(OrderAmount) OrderAmount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM Orders&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WHERE TO_CHAR(OrderDate,'YYYY') = $(vYear)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AND&amp;nbsp;TO_CHAR(OrderDate,'MM') &lt;STRONG&gt;IN&lt;/STRONG&gt; $(vMonth)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;How can I make the SQL to work with a &lt;STRONG&gt;IN&lt;/STRONG&gt; condition when the variable &lt;STRONG&gt;vMonth&lt;/STRONG&gt;&amp;nbsp;is having multiple values?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly help.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 19:08:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2156907#M93729</guid>
      <dc:creator>satya_s</dc:creator>
      <dc:date>2023-12-29T19:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from filter to a SQL query in data load script?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157023#M93734</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/95888"&gt;@satya_s&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using the CONCAT() function to get all values in the month field into a comma separated list and pass it in the IN statement. See if that works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;vMonth = concat(GetFieldSelections(MonthID),',')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;Björn&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 14:09:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157023#M93734</guid>
      <dc:creator>Bjorn_Wedbratt</dc:creator>
      <dc:date>2023-12-30T14:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from filter to a SQL query in data load script?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157088#M93743</link>
      <description>&lt;P&gt;use concat function to store multiple values in variable&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Concat(DISTINCT GetFieldSelections(Month),', ')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense/November2023/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/StringAggregationFunctions/concat.htm#:~:text=Concat()%20is%20used%20to,expression%20evaluated%20over%20each%20dimension.&amp;amp;text=The%20expression%20or%20field%20containing%20the%20string%20to%20be%20processed.&amp;amp;text=Each%20value%20may%20be%20separated%20by%20the%20string%20found%20in%20delimiter" target="_blank"&gt;https://help.qlik.com/en-US/sense/November2023/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/StringAggregationFunctions/concat.htm#:~:text=Concat()%20is%20used%20to,expression%20evaluated%20over%20each%20dimension.&amp;amp;text=The%20expression%20or%20field%20containing%20the%20string%20to%20be%20processed.&amp;amp;text=Each%20value%20may%20be%20separated%20by%20the%20string%20found%20in%20delimiter&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2023 04:00:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157088#M93743</guid>
      <dc:creator>anat</dc:creator>
      <dc:date>2023-12-31T04:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from filter to a SQL query in data load script?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157479#M93774</link>
      <description>&lt;P&gt;It depends mainly on the from the data-base supported syntax. I suggest you comment the month-variable at first and writes two month manually within the in() or in "...." or whatever the data-base recognized. If it worked you shows the variable-content within a text-box until it looked like your hard-coded values.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 14:11:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157479#M93774</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-01-02T14:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from filter to a SQL query in data load script?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157491#M93777</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/47358"&gt;@anat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your reply. When I am selecting the filter, the multiple values are already comings with a comma delimiter. The issue was with the SQL formation.&lt;/P&gt;
&lt;P&gt;The curly brackets after the IN statement needs to be explicitly defined for the SQL to work. I changed the SQL query to the one below and then it worked.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SELECT COUNT(OrderID) NoOfOrders, SUM(OrderAmount) OrderAmount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM Orders&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WHERE TO_CHAR(OrderDate,'YYYY') = $(vYear)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AND&amp;nbsp;TO_CHAR(OrderDate,'MM')&amp;nbsp;&lt;STRONG&gt;IN (&lt;/STRONG&gt;&amp;nbsp;$(vMonth) )&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks once again for looking into it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 14:28:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157491#M93777</guid>
      <dc:creator>satya_s</dc:creator>
      <dc:date>2024-01-02T14:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from filter to a SQL query in data load script?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157492#M93778</link>
      <description>&lt;P&gt;Hi Marcus,&lt;/P&gt;
&lt;P&gt;Thanks for your reply. I managed to make it work by explicitly putting the curly brackets in the&lt;SPAN&gt;&amp;nbsp;SQL.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SELECT COUNT(OrderID) NoOfOrders, SUM(OrderAmount) OrderAmount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM Orders&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WHERE TO_CHAR(OrderDate,'YYYY') = $(vYear)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AND&amp;nbsp;TO_CHAR(OrderDate,'MM')&amp;nbsp;&lt;STRONG&gt;IN (&lt;/STRONG&gt;&amp;nbsp;$(vMonth) )&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks once again for looking into it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 14:30:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-pass-multiple-values-from-filter-to-a-SQL-query-in-data/m-p/2157492#M93778</guid>
      <dc:creator>satya_s</dc:creator>
      <dc:date>2024-01-02T14:30:13Z</dc:date>
    </item>
  </channel>
</rss>

