<?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: Last balance value in pivot in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Last-balance-value-in-pivot/m-p/453143#M485424</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have a calendar table in your QV data model?&amp;nbsp; If not, create one. There are lots of examples in this forum of how to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One way of getting what you want is to ensure you have IsMonthEnd and IsWeekEnd fields in the calendar model. You can create these in the calendar load by:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If(Date=MonthEnd(Date),1,0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsMonthEnd&lt;/P&gt;&lt;P&gt;,If(Date=WeekEnd(Date)-2,1,0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsWeekEnd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, in your chart with Week as the last dimension your expression can be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;IsWeekEnd={1}&amp;gt;} Balance)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And in the chart to month level:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;IsMonthEnd={1}&amp;gt;} Balance)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Apr 2013 10:06:53 GMT</pubDate>
    <dc:creator>Jason_Michaelides</dc:creator>
    <dc:date>2013-04-15T10:06:53Z</dc:date>
    <item>
      <title>Last balance value in pivot</title>
      <link>https://community.qlik.com/t5/QlikView/Last-balance-value-in-pivot/m-p/453142#M485423</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 have a problem with getting the last value of balance sheet accounts in the pivot table. Does anybody has an expression which could do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My case is like this:&lt;/P&gt;&lt;P&gt;- closing balances are calculated in the script for every account and every day&lt;/P&gt;&lt;P&gt;- I need to get a pivot table where dimensions are month, week and accounts group&lt;/P&gt;&lt;P&gt;- I need to get an expression where for any shown period it sums the balances for all selected accounts but only from the last day of that period&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attached an excel whit desired result.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 07:46:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Last-balance-value-in-pivot/m-p/453142#M485423</guid>
      <dc:creator>RadovanOresky</dc:creator>
      <dc:date>2013-04-15T07:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Last balance value in pivot</title>
      <link>https://community.qlik.com/t5/QlikView/Last-balance-value-in-pivot/m-p/453143#M485424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have a calendar table in your QV data model?&amp;nbsp; If not, create one. There are lots of examples in this forum of how to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One way of getting what you want is to ensure you have IsMonthEnd and IsWeekEnd fields in the calendar model. You can create these in the calendar load by:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If(Date=MonthEnd(Date),1,0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsMonthEnd&lt;/P&gt;&lt;P&gt;,If(Date=WeekEnd(Date)-2,1,0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsWeekEnd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, in your chart with Week as the last dimension your expression can be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;IsWeekEnd={1}&amp;gt;} Balance)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And in the chart to month level:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;IsMonthEnd={1}&amp;gt;} Balance)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 10:06:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Last-balance-value-in-pivot/m-p/453143#M485424</guid>
      <dc:creator>Jason_Michaelides</dc:creator>
      <dc:date>2013-04-15T10:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Last balance value in pivot</title>
      <link>https://community.qlik.com/t5/QlikView/Last-balance-value-in-pivot/m-p/453144#M485425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, this works nicely in the restricted circumstances. Trouble is when adding accounts group dimension in front of the month. When I collapse, it will show the sum of balances, but the last balance from the last month is needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used this expression, which works until date level, but without week level:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;If(Sum({&amp;lt;IsMonthEnd={1}&amp;gt;}Balance)=0, Sum(Balance), &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Sum({&amp;lt;IsMonthEnd={1}&amp;gt;}Balance))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Then, when the pivot is expanded on monthly level it works fine, e.g.:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" height="68" style="border: 1px solid #000000; width: 263px; height: 64px;" width="263"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Account Group&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Month&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Balance&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Group1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Group1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;But when I collapse the group, the sum is incorrect, e.g.:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" height="52" style="border: 1px solid rgb(0, 0, 0); width: 314px; height: 52px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Account Group&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Balance&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Group1&lt;/TD&gt;&lt;TD&gt;300 - but should be 200&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Also, when I want to have month and week in the same pivot and I expand the expression, then when the date for the end of the week is the same as the date for the end of the month, value will duplicate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I guess I hoped there is a more general function, which would always show the last value (timewise) for whichever dimension. I will try to optimize it further.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But really thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 13:30:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Last-balance-value-in-pivot/m-p/453144#M485425</guid>
      <dc:creator>RadovanOresky</dc:creator>
      <dc:date>2013-04-15T13:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Last balance value in pivot</title>
      <link>https://community.qlik.com/t5/QlikView/Last-balance-value-in-pivot/m-p/453145#M485426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not that it matters anymore, but I solved the problem with &lt;STRONG&gt;FirstSortedValue()&lt;/STRONG&gt; function.&lt;/P&gt;&lt;P&gt;The expression was &lt;EM&gt;FirstSortedValue( Aggr( Sum(Balance), Date ), -Date)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This blog post by HIC expains the approaches to non-additive numbers, like Account Balance.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4647"&gt;Additive and Non-Additive Numbers&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Radovan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2018 20:32:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Last-balance-value-in-pivot/m-p/453145#M485426</guid>
      <dc:creator>RadovanOresky</dc:creator>
      <dc:date>2018-11-05T20:32:26Z</dc:date>
    </item>
  </channel>
</rss>

