<?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: MSSQL Server Query in QlikView in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408074#M806742</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to use group by clause for aggregate functions&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 21 Oct 2017 13:06:40 GMT</pubDate>
    <dc:creator>Anil_Babu_Samineni</dc:creator>
    <dc:date>2017-10-21T13:06:40Z</dc:date>
    <item>
      <title>MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408073#M806741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following SQL Query which i am executing in MSSQL Server Management Studio:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas;"&gt;&lt;SPAN style="color: #0433ff;"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN style="color: #ff40ff;"&gt;COUNT&lt;/SPAN&gt;&lt;SPAN style="color: #929292;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0433ff;"&gt;DISTINCT&lt;/SPAN&gt; [Script Number]&lt;SPAN style="color: #929292;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;AS&lt;/SPAN&gt; RxCount&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas;"&gt;&lt;SPAN style="color: #0433ff;"&gt;FROM&lt;/SPAN&gt; tblDatawarehouseConsolidatedCleanStage &lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas;"&gt;&lt;SPAN style="color: #0433ff;"&gt;WHERE&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="color: #929292;"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #ff2600;"&gt;'2017-09-01'&lt;/SPAN&gt; &lt;SPAN style="color: #929292;"&gt;and&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="color: #929292;"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN style="color: #ff2600;"&gt;'2017-09-30'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas;"&gt;&lt;SPAN style="color: #ff2600;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN&gt;How can the above SQL Query be executed in QlikView load script statement?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas;"&gt;&lt;SPAN style="color: #ff2600;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas;"&gt;&lt;SPAN style="color: #000000;"&gt;Regards.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas;"&gt;&lt;SPAN style="color: #ff2600;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff2600;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408073#M806741</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408074#M806742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to use group by clause for aggregate functions&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 13:06:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408074#M806742</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2017-10-21T13:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408075#M806743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try with the below statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;COUNT(DISTINCT [Script Number]) AS RxCount&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;WHERE [Date Dispensed] &amp;gt;= '2017-09-01' and [Date Dispensed] &amp;lt;= '2017-09-30';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;sql select &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FROM tblDatawarehouseConsolidatedCleanStage;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 13:29:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408075#M806743</guid>
      <dc:creator>its_anandrjs</dc:creator>
      <dc:date>2017-10-21T13:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408076#M806744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks Anil&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i use a group by clause, the value of "Rxcount" i get in QlikView is overstated compared to the one i get directly in MSSQL Server Management Studio.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 13:30:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408076#M806744</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-21T13:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408077#M806745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Anand, let me try it out and advise accordingly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 13:30:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408077#M806745</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-21T13:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408078#M806746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a specific reason you want to extract all the records from the Sql Server table &lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;tblDatawarehouseConsolidatedCleanStage,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;transfer all the records from Sql Server to Qlik and then calculate in Qlik a single value, the count distinct ....?&lt;/P&gt;&lt;P&gt;Why not just a &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #0433ff;"&gt;SQL SELECT&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #ff40ff;"&gt;COUNT&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #929292;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #0433ff;"&gt;DISTINCT&lt;/SPAN&gt; [Script Number]&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #929292;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #0433ff;"&gt;AS&lt;/SPAN&gt; RxCount&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #0433ff;"&gt;FROM&lt;/SPAN&gt; tblDatawarehouseConsolidatedCleanStage&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #0433ff;"&gt;WHERE&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #929292;"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #ff2600;"&gt;'2017-09-01'&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #929292;"&gt;and&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #929292;"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #ff2600;"&gt;'2017-09-30'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #ff2600;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;in Qlik?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 13:49:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408078#M806746</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2017-10-21T13:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408079#M806747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Massimo, doesn't the 'count' statement require a Group By clause?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 14:05:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408079#M806747</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-21T14:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408080#M806748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no, it doesn't&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use the group by, it depends on what you want to achieve&lt;/P&gt;&lt;P&gt;example: &lt;/P&gt;&lt;P&gt;input data is on the left,&lt;/P&gt;&lt;P&gt;the result of the query is on the right &lt;/P&gt;&lt;P&gt;- right top: count distinct&lt;/P&gt;&lt;P&gt;- right bottom: count distinct with a group by dim &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="1.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/180469_1.png" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 14:26:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408080#M806748</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2017-10-21T14:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408081#M806751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Group by is mandatory where aggregations line sum, count ... to persists you can try with this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;&lt;STRONG&gt;Load:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;STRONG style="color: #000000; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;&lt;SPAN style="font-style: inherit;"&gt;SELECT &lt;/SPAN&gt; [Script Number], [Date Dispersed]&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;STRONG style="color: #000000; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;&lt;SPAN style="font-style: inherit;"&gt;FROM&lt;/SPAN&gt; tblDatawarehouseConsolidatedCleanStage&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;STRONG style="color: #000000; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;&lt;SPAN style="font-style: inherit;"&gt;WHERE&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-style: inherit;"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN style="font-style: inherit;"&gt;'2017-09-01'&lt;/SPAN&gt; &lt;SPAN style="font-style: inherit;"&gt;and&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-style: inherit;"&gt;&amp;lt;=&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit;"&gt;'2017-09-30';&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;STRONG style="color: #000000; font-size: 10pt; font-style: inherit; font-family: arial, helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;STRONG style="color: #000000; font-size: 10pt; font-style: inherit; font-family: arial, helvetica, sans-serif;"&gt;Load [Date Dispensed], count([Script Number] as RxCount Resident Load&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #000000; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;&lt;STRONG&gt;Group by [Date Dispensed];&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 14:41:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408081#M806751</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2017-10-21T14:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408082#M806753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason why i am calculating RxCount at load step in the front end is that i need to use it in QV complex scripts like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 9px; font-family: Arial; color: #941100;"&gt;&lt;SPAN style="color: #0433ff;"&gt;Num&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0433ff;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;({&amp;lt;&lt;/SPAN&gt;[Date Dispensed]&lt;SPAN style="color: #000000;"&gt;={&lt;/SPAN&gt;"&amp;gt;=$(=addmonths(MonthEnd(max([Date Dispensed]))+1,-12)) &amp;lt;=$(=max([Date Dispensed]))"&lt;SPAN style="color: #000000;"&gt;}&amp;gt;}&lt;/SPAN&gt;RxCount&lt;SPAN style="color: #000000;"&gt;), '#,##0') &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9px; font-family: Arial; color: #941100;"&gt;&lt;/P&gt;&lt;P style="font-size: 9px; font-family: Arial; color: #941100;"&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 15:24:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408082#M806753</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-21T15:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408083#M806754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;Some options:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;1) load the fields [Script Number] and [Date Dispensed] without group by and calculate in the chart&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: arial, helvetica, sans-serif; color: #0433ff; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: arial, helvetica, sans-serif; color: #0433ff; font-size: 10pt;"&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;SQL&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;SELECT&lt;/SPAN&gt; [Script Number&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;]&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;AS&lt;/SPAN&gt; RxCount, [Date Dispensed]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;FROM&lt;/SPAN&gt; tblDatawarehouseConsolidatedCleanStage&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #0000ff;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;WHERE&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;'2017-09-01'&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;and&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 8pt; font-weight: inherit;"&gt;'2017-09-30';&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: arial, helvetica, sans-serif; color: #ff2600; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;2) group by date in the sql section of the Qlik load&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;&lt;SPAN style="color: #339966; font-size: 8pt;"&gt;Load *;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: arial, helvetica, sans-serif; color: #0433ff; font-size: 8pt;"&gt;&lt;SPAN style="color: #0000ff;"&gt;SQL&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: arial, helvetica, sans-serif; color: #0000ff; font-size: 8pt;"&gt;SELECT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; COUNT(DISTINCT [Script Number]) &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;AS&lt;/SPAN&gt; RxCount,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Date Dispensed]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;FROM&lt;/SPAN&gt; tblDatawarehouseConsolidatedCleanStage&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;WHERE&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;'2017-09-01'&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;and&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;'2017-09-30'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-style: inherit; font-size: 8pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;group by [Date Dispensed];&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;3) &lt;SPAN style="color: #3d3d3d;"&gt;group by date in the Qlik section of the Qlik preceding load&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d; background-color: #f2f2f2;"&gt;&lt;SPAN style="color: #008000; font-size: 8pt; font-family: arial, helvetica, sans-serif;"&gt;Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d; background-color: #f2f2f2;"&gt;&lt;SPAN style="font-size: 8pt; font-family: arial, helvetica, sans-serif; color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Date Dispensed],&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d; background-color: #f2f2f2;"&gt;&lt;SPAN style="font-size: 8pt; font-family: arial, helvetica, sans-serif; color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(distinct [Script Number]) as RxCount&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d; background-color: #f2f2f2;"&gt;&lt;SPAN style="color: #008000; font-style: inherit; font-size: 8pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;Group by [Date Dispensed];&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-style: inherit; font-size: 8pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;SELECT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Script Number&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;]&lt;/SPAN&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Date Dispensed]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;FROM&lt;/SPAN&gt; tblDatawarehouseConsolidatedCleanStage&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 9.5px; font-family: Consolas; color: #3d3d3d;"&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, sans-serif; font-size: 8pt;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;WHERE&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;'2017-09-01'&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;and&lt;/SPAN&gt; [Date Dispensed] &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-style: inherit; font-size: 8pt; font-family: arial, helvetica, sans-serif; font-weight: inherit;"&gt;'2017-09-30';&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Oct 2017 17:24:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408083#M806754</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2017-10-21T17:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: MSSQL Server Query in QlikView</title>
      <link>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408084#M806755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Massimo.&amp;nbsp; Part of my model is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="180488" alt="Screen Shot 2017-22-10 at 10-37-12.png" class="jive-image image-1" src="/legacyfs/online/180488_Screen Shot 2017-22-10 at 10-37-12.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;The total number of Prescriptions dispensed (Rx) in my data is 5 151 692 which i got through a select distinct [Script Number] in MSSQL Server Management studio.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did a normal load and added a variable Rx calculated as follows:&lt;/P&gt;&lt;P style="font-size: 9px; font-family: Arial; color: #941100;"&gt;&lt;SPAN style="color: #000000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0433ff;"&gt;Count&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0433ff;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;[Script Number]&lt;SPAN style="color: #000000;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I then want to get the prescriptions dispensed for month to date through set analysis as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&lt;SPAN style="color: #0433ff;"&gt;Num&lt;/SPAN&gt;(&lt;SPAN style="color: #0433ff;"&gt;Sum&lt;/SPAN&gt;({$&amp;lt;&lt;SPAN style="color: #929292;"&gt;&lt;STRONG&gt;&lt;EM&gt;$(vSetMTD)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;gt;}Rx), '#,##0')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This figure gives the value of 5 151 692 (the total number of prescriptions) meaning that it is not responding to set analysis or selections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Screen Shot 2017-22-10 at 11-10-10.png" class="jive-image image-3" src="/legacyfs/online/180490_Screen Shot 2017-22-10 at 11-10-10.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;The percentage is the change over the last period, is zero meaning a constant figure of 5 151 692 is being returned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A table which summarises the prescription count (script count) per retail outlet also gives total values as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Screen Shot 2017-22-10 at 11-07-20.png" class="jive-image image-2" src="/legacyfs/online/180489_Screen Shot 2017-22-10 at 11-07-20.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;However in the same model i have the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=Num(Sum({$&amp;lt;$(vSetMTD)&amp;gt;}Amount), '$##,##0.00')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above gives the right value of total value of prescriptions dispensed month to date and the "Amount" is loaded in the front end which is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Screen Shot 2017-22-10 at 11-09-49.png" class="image-4 jive-image" src="/legacyfs/online/180491_Screen Shot 2017-22-10 at 11-09-49.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What could be taking place?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Oct 2017 08:57:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MSSQL-Server-Query-in-QlikView/m-p/1408084#M806755</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-22T08:57:34Z</dc:date>
    </item>
  </channel>
</rss>

