<?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 Subquery possible in a straight table? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304902#M112636</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a straight table with the intention of producing a single total…&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to count the number of hospital beds in use per day – it must be a distinct count as one bed may have more than one patient over the course of 24 hours.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then need to sum the daily figures to produce a monthly figure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SQL it looks like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;select&lt;/SPAN&gt; &lt;SPAN style="color: fuchsia;"&gt;SUM&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt;Beds&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; TotalBeds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;from &lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: blue;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; full_date&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="color: fuchsia;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: blue;"&gt;distinct&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; BedID&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; Beds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; #temp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; BedOpen &lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; full_date&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; sub&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I came up with this but the figure is miles out: &lt;SPAN style="color: black;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: purple;"&gt;sum&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: green;"&gt;distinct&lt;/STRONG&gt; &lt;STRONG style="color: green;"&gt;total&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;STRONG style="color: green;"&gt;INP_full_date&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;STRONG style="color: purple;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: green;"&gt;INP_BedOpen&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #4d0000;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: green;"&gt;INP_BedID&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can get the correct figure if I sum the number of rows in a straight table – the problem is I just to display a single figure rather than numerous rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, Michael.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Feb 2012 15:46:06 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-02-21T15:46:06Z</dc:date>
    <item>
      <title>Subquery possible in a straight table?</title>
      <link>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304902#M112636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a straight table with the intention of producing a single total…&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to count the number of hospital beds in use per day – it must be a distinct count as one bed may have more than one patient over the course of 24 hours.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then need to sum the daily figures to produce a monthly figure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SQL it looks like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;select&lt;/SPAN&gt; &lt;SPAN style="color: fuchsia;"&gt;SUM&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt;Beds&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; TotalBeds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;from &lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: blue;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; full_date&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="color: fuchsia;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: blue;"&gt;distinct&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; BedID&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; Beds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; #temp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; BedOpen &lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: blue;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; full_date&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: windowtext;"&gt; sub&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I came up with this but the figure is miles out: &lt;SPAN style="color: black;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: purple;"&gt;sum&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: green;"&gt;distinct&lt;/STRONG&gt; &lt;STRONG style="color: green;"&gt;total&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;STRONG style="color: green;"&gt;INP_full_date&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;STRONG style="color: purple;"&gt;if&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: green;"&gt;INP_BedOpen&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #4d0000;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: green;"&gt;INP_BedID&lt;/STRONG&gt;&lt;SPAN style="color: black;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can get the correct figure if I sum the number of rows in a straight table – the problem is I just to display a single figure rather than numerous rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, Michael.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 15:46:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304902#M112636</guid>
      <dc:creator />
      <dc:date>2012-02-21T15:46:06Z</dc:date>
    </item>
    <item>
      <title>Subquery possible in a straight table?</title>
      <link>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304903#M112637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It might be helpful if you could post your current dimension(s) and expressions in the table.&lt;/P&gt;&lt;P&gt;From your SQL, I would suggest&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum( aggr( count({&amp;lt;BedOpen={1}&amp;gt;} distinct BedID), full_date))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 16:41:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304903#M112637</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-02-21T16:41:04Z</dc:date>
    </item>
    <item>
      <title>Subquery possible in a straight table?</title>
      <link>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304904#M112638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;Many thanks swuehl.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;I tried your code – it’s returning a value of 0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;In my table I have the dimension &lt;/SPAN&gt;&lt;STRONG style="color: green; font-size: 9pt; font-family: 'Arial','sans-serif';"&gt;full_date &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;And the expression (for which I have set Total Mode to Sum of Rows):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: purple; font-size: 9pt; font-family: 'Arial','sans-serif';"&gt;count&lt;/STRONG&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: green; font-size: 9pt; font-family: 'Arial','sans-serif';"&gt;distinct&lt;/STRONG&gt; &lt;STRONG style="color: purple; font-size: 9pt; font-family: 'Arial','sans-serif';"&gt;if&lt;/STRONG&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt; (&lt;/SPAN&gt;&lt;STRONG style="color: green; font-size: 9pt; font-family: 'Arial','sans-serif';"&gt;BedOpen&lt;/STRONG&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt; = &lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; color: #4d0000; font-family: 'Arial','sans-serif';"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: green; font-size: 9pt; font-family: 'Arial','sans-serif';"&gt;BedID&lt;/STRONG&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; color: #1f497d; font-family: 'Calibri','sans-serif';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;The sum total is giving the correct total.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;What I need to do is reproduce the sum total independently from the table (for example in a text box).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; color: black; font-family: 'Arial','sans-serif';"&gt;Thanks again, Michael.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 16:52:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304904#M112638</guid>
      <dc:creator />
      <dc:date>2012-02-21T16:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Subquery possible in a straight table?</title>
      <link>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304905#M112639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the expression should work in principal, see also attached sample (the textbox is using my expression).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you checked the exact spelling / cases of all field names etc?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you check my attached sample and compare it to your data model? Maybe I have made assumptions that are not correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 17:35:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304905#M112639</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-02-21T17:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Subquery possible in a straight table?</title>
      <link>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304906#M112640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perfect – thanks Stefan, really appreciate it.&lt;SPAN style="font-size: 11pt; font-family: 'Calibri','sans-serif';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 10:01:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subquery-possible-in-a-straight-table/m-p/304906#M112640</guid>
      <dc:creator />
      <dc:date>2012-02-22T10:01:54Z</dc:date>
    </item>
  </channel>
</rss>

