<?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: Incorrect totals in a pivot table using set analysis in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Incorrect-totals-in-a-pivot-table-using-set-analysis/m-p/330800#M121830</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The general way to get a sum of rows in a pivot table is like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;sum(aggr(YourExpressionHere,YourDimensionsHere))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The set expression would need to be repeated on the new sum(), so I believe you'd need this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;sum({$&amp;lt;[Finance Date] = {'&amp;gt;=$(=MonthStart(Date(vStartDate)))&amp;lt;=$(=Date(vEndDate))'} &amp;gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;aggr(IF(Count( {$&amp;lt;[Finance Date] = {'&amp;gt;=$(=MonthStart(Date(vStartDate)))&amp;lt;=$(=Date(vEndDate))'} &amp;gt;} [Finance Performance ID]) &amp;gt;= $(vDateDiff),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;SUM( {$&amp;lt;[Finance Date] = {'&amp;gt;=$(=MonthStart(Date(vStartDate)))&amp;lt;=$(=Date(vEndDate))'} &amp;gt;} [Total Revenue]),NULL)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,&lt;EM&gt;YourDimensionsHere&lt;/EM&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And of course replace "YourDimensionsHere" with your actual chart dimensions, comma delimited.&amp;nbsp; You may want to use a variable for your set expression to avoid repeating it this many times.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Mar 2012 22:32:06 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2012-03-30T22:32:06Z</dc:date>
    <item>
      <title>Incorrect totals in a pivot table using set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Incorrect-totals-in-a-pivot-table-using-set-analysis/m-p/330799#M121829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a small issue trying to add the sumtotals correctly in a pivot table.&amp;nbsp; My set analysis for the table currently has an IF statement, and selecting the date range for the calendar consists of two variables (vStartDate and vEndDate). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The IF statement determines if the number of rows submitted equals the number of months between the start and end dates.&amp;nbsp; My dilemma is calculating the totals.&amp;nbsp; When a row has a NULL in an expression because of an invalid time range, it may still have a value in the database.&amp;nbsp; This value is being used to calculate the total, even though it is displayed as a NULL on the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I incorporate my IF condition (comparing count of rows to the number of months between the start and end dates) into the second line of my expression?&amp;nbsp; So it would serve as a filter for my SUM statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;________________________________________________&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=IF(Count( {$&amp;lt;[Finance Date] = {'&amp;gt;=$(=MonthStart(Date(vStartDate)))&amp;lt;=$(=Date(vEndDate))'} &amp;gt;} [Finance Performance ID]) &amp;gt;= $(vDateDiff),&lt;/P&gt;&lt;P&gt;SUM( {$&amp;lt;[Finance Date] = {'&amp;gt;=$(=MonthStart(Date(vStartDate)))&amp;lt;=$(=Date(vEndDate))'} &amp;gt;} [Total Revenue]),NULL)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE vDateDiff is a variable defined as:&amp;nbsp; round(($(=vStartDate)-$(=vEndDate)) / 30.25)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 21:26:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Incorrect-totals-in-a-pivot-table-using-set-analysis/m-p/330799#M121829</guid>
      <dc:creator />
      <dc:date>2012-03-30T21:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect totals in a pivot table using set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Incorrect-totals-in-a-pivot-table-using-set-analysis/m-p/330800#M121830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The general way to get a sum of rows in a pivot table is like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;sum(aggr(YourExpressionHere,YourDimensionsHere))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The set expression would need to be repeated on the new sum(), so I believe you'd need this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;sum({$&amp;lt;[Finance Date] = {'&amp;gt;=$(=MonthStart(Date(vStartDate)))&amp;lt;=$(=Date(vEndDate))'} &amp;gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;aggr(IF(Count( {$&amp;lt;[Finance Date] = {'&amp;gt;=$(=MonthStart(Date(vStartDate)))&amp;lt;=$(=Date(vEndDate))'} &amp;gt;} [Finance Performance ID]) &amp;gt;= $(vDateDiff),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;SUM( {$&amp;lt;[Finance Date] = {'&amp;gt;=$(=MonthStart(Date(vStartDate)))&amp;lt;=$(=Date(vEndDate))'} &amp;gt;} [Total Revenue]),NULL)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,&lt;EM&gt;YourDimensionsHere&lt;/EM&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And of course replace "YourDimensionsHere" with your actual chart dimensions, comma delimited.&amp;nbsp; You may want to use a variable for your set expression to avoid repeating it this many times.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 22:32:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Incorrect-totals-in-a-pivot-table-using-set-analysis/m-p/330800#M121830</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2012-03-30T22:32:06Z</dc:date>
    </item>
  </channel>
</rss>

