<?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 Total amount wrong calculated in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543764#M109595</link>
    <description>&lt;P&gt;If i use the "IF...Then" statement in a pivot table to control how the value must be calculated the total amount of this column is wrong.&lt;/P&gt;&lt;P&gt;The potential sales quantity should be determined based on the order backlog and the currently available quantity.&lt;/P&gt;&lt;P&gt;If the quantity on stock is less then the backlog order quantity of the item the quantity on stock should be used, otherwise the backlog quantity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=If(&lt;BR /&gt;sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}Stock_Quant) &amp;lt; sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}BCK_Quant),&lt;/P&gt;&lt;P&gt;//Then&lt;BR /&gt;sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}Stock_Quant)&lt;BR /&gt;,&lt;/P&gt;&lt;P&gt;//Else&lt;BR /&gt;sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}BCK_Quant))&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The total value for the "potential sales quantity" shows the total of the backlog quantity.&lt;/P&gt;&lt;P&gt;But there are many items with less or zero quantity on stock. So the calculated&amp;nbsp;"potential sales quantity" must be far less then the&amp;nbsp;backlog quantity.&lt;/P&gt;&lt;P&gt;If i export the data to excel and calculate the total of the&amp;nbsp;"potential sales quantity" column i get the correct quantities.&lt;/P&gt;&lt;P&gt;That means the calucalted value in the rows are correct but not the total value on top of the pivot table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Strange is also, this problem only exist if there is no filter group activ.&lt;BR /&gt;If i filter the items by item number or item group or any other possible properties the calculation of the total is correct.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Feb 2026 16:24:34 GMT</pubDate>
    <dc:creator>Thomas_G</dc:creator>
    <dc:date>2026-02-25T16:24:34Z</dc:date>
    <item>
      <title>Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543764#M109595</link>
      <description>&lt;P&gt;If i use the "IF...Then" statement in a pivot table to control how the value must be calculated the total amount of this column is wrong.&lt;/P&gt;&lt;P&gt;The potential sales quantity should be determined based on the order backlog and the currently available quantity.&lt;/P&gt;&lt;P&gt;If the quantity on stock is less then the backlog order quantity of the item the quantity on stock should be used, otherwise the backlog quantity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=If(&lt;BR /&gt;sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}Stock_Quant) &amp;lt; sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}BCK_Quant),&lt;/P&gt;&lt;P&gt;//Then&lt;BR /&gt;sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}Stock_Quant)&lt;BR /&gt;,&lt;/P&gt;&lt;P&gt;//Else&lt;BR /&gt;sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}BCK_Quant))&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The total value for the "potential sales quantity" shows the total of the backlog quantity.&lt;/P&gt;&lt;P&gt;But there are many items with less or zero quantity on stock. So the calculated&amp;nbsp;"potential sales quantity" must be far less then the&amp;nbsp;backlog quantity.&lt;/P&gt;&lt;P&gt;If i export the data to excel and calculate the total of the&amp;nbsp;"potential sales quantity" column i get the correct quantities.&lt;/P&gt;&lt;P&gt;That means the calucalted value in the rows are correct but not the total value on top of the pivot table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Strange is also, this problem only exist if there is no filter group activ.&lt;BR /&gt;If i filter the items by item number or item group or any other possible properties the calculation of the total is correct.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 16:24:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543764#M109595</guid>
      <dc:creator>Thomas_G</dc:creator>
      <dc:date>2026-02-25T16:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543815#M109600</link>
      <description>&lt;P&gt;In Dimension properties are you apply correct aggression method for total&amp;nbsp; as sum or is it auto?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2026 08:41:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543815#M109600</guid>
      <dc:creator>vighnesh_gawad</dc:creator>
      <dc:date>2026-02-26T08:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543816#M109601</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;I can not find the option to define the aggregation method?&lt;BR /&gt;please look at the picture.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2026 09:36:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543816#M109601</guid>
      <dc:creator>Thomas_G</dc:creator>
      <dc:date>2026-02-26T09:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543817#M109602</link>
      <description>&lt;P&gt;To ensure that your total returns the sum/avg/... of the object-rows you could wrap your calculation with an aggr(), like:&lt;/P&gt;&lt;P&gt;sum(aggr(myCalculation, Dim1, Dim2))&lt;/P&gt;&lt;P&gt;whereby Dim1 and Dim2 are just place-holder for the needed dimensional-context (usually the ones from the chart).&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2026 09:44:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543817#M109602</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2026-02-26T09:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543820#M109603</link>
      <description>&lt;P&gt;Ok. But with aggr() a error is shown. -&amp;gt; &lt;STRONG&gt;"Aggr takes at least 2 parameters"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sum(&lt;STRONG&gt;aggr(&lt;/STRONG&gt;{$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}Menge_vorhanden&lt;STRONG&gt;)&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2026 10:12:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543820#M109603</guid>
      <dc:creator>Thomas_G</dc:creator>
      <dc:date>2026-02-26T10:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543825#M109604</link>
      <description>&lt;P&gt;Like hinted you need to specify the dimensions in which context the calculation should be performed:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sum(aggr(myCalculation, &lt;STRONG&gt;Dim1, Dim2&lt;/STRONG&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;and the aggr() here is meant as a single aggr() around your if-query.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2026 10:26:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543825#M109604</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2026-02-26T10:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543835#M109605</link>
      <description>&lt;P&gt;Sorry, but i do not real understand what you mean with dimension-context.&lt;/P&gt;&lt;P&gt;I have tried with a much simpler formula to wrap some sum() in aggr() and otherwise. But i get wrong or null values.&lt;/P&gt;&lt;P&gt;This works fine:&lt;/P&gt;&lt;P&gt;=if(sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}AB_Betrag) &amp;gt; 0,&lt;BR /&gt;&lt;STRONG&gt;sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}Menge_vorhanden),&lt;/STRONG&gt;&lt;BR /&gt;0)&lt;/P&gt;&lt;P&gt;How to include aggr() in such a working formula?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2026 11:13:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543835#M109605</guid>
      <dc:creator>Thomas_G</dc:creator>
      <dc:date>2026-02-26T11:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543841#M109606</link>
      <description>&lt;P&gt;something like this maybe:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;if(Sum(Aggr(sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}AB_Betrag),Artikel, Kunde, Jahr, Monat)) &amp;gt; 0,
	Sum(Aggr(sum({$&amp;lt;Jahr={"$(#=year(today()))"},Monat={"$(#=month(today()))"}&amp;gt;}Menge_vorhanden),Artikel, Kunde, Jahr, Monat)),
	0
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 26 Feb 2026 12:34:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543841#M109606</guid>
      <dc:creator>BIAKS</dc:creator>
      <dc:date>2026-02-26T12:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543842#M109607</link>
      <description>&lt;P&gt;Each calculation has always a dimensional-context.&lt;/P&gt;&lt;P&gt;Example: a simple pivot with Customer and Period as vertical/horizontal dimension and an expression like: sum(Value) calculates n results - one for each cell respectively the dimensional-context. In such case no aggr() would be needed because the total would be always the sum of the rows.&lt;/P&gt;&lt;P&gt;But as far as any conditions are applied or rates calculated the total mustn't be mandatory the sum of the rows because the conditions/rates aren't equally the same for the total and each object-row.&lt;/P&gt;&lt;P&gt;Imagine that the Customers have an individual discount depending on previous sales or special contracts. If now an expression like: sum(RawSales * Discount) is used it would return the correct results on the row-level but the total must go wrong because it wouldn't respect the right discount. The solution would be to enforce the calculation on the needed dimensional-context and then summing the results within the total. For this example it would be:&lt;/P&gt;&lt;P&gt;sum(aggr(sum(RawSales * Discount), &lt;STRONG&gt;Customer&lt;/STRONG&gt;))&lt;/P&gt;&lt;P&gt;whereby Customer is here the dimensional-context for the calculation of:&amp;nbsp;sum(RawSales * Discount). Extending the considerations to an discount exclusion of zero-margin categories the expression may look like:&lt;/P&gt;&lt;P&gt;sum(aggr(sum(RawSales * Discount), &lt;STRONG&gt;Customer, Category&lt;/STRONG&gt;))&lt;/P&gt;&lt;P&gt;which may not mandatory need an included dimension of the object. This means the fields which define the dimensional-context might be included within the object but mustn't as well as it's not always necessary to specify all object-fields as aggr-dimension - it depends to detailed scenario.&lt;/P&gt;&lt;P&gt;I suggest not to start to try to apply the aggr-approach within your origin table else creating a new one with just two dimensions and a single expression to play with it and to comprehend the logic. If this is done is adapting it to the origin table much more easy.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2026 12:50:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543842#M109607</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2026-02-26T12:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543868#M109608</link>
      <description>&lt;P&gt;Hello Marcus_Sommer,&lt;/P&gt;&lt;P&gt;thank you very much for the&amp;nbsp;detailed explanation.&amp;nbsp;But i am still not able to find a solution for the wrong total values.&lt;/P&gt;&lt;P&gt;So, i have created a tiny app with Inline Data, which show the problem. Attached.&lt;BR /&gt;The problem is also marked in the attached image.&lt;/P&gt;&lt;P&gt;I hope someone could find a solution.&lt;BR /&gt;Thanks a lot in forehand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If not, than i will look to fix this with a new view in the database to calculate the values while loading.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2026 15:28:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543868#M109608</guid>
      <dc:creator>Thomas_G</dc:creator>
      <dc:date>2026-02-26T15:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543890#M109610</link>
      <description>&lt;P&gt;You can easily solve it like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;=Sum(Aggr(
If(
Sum(Aggr(sum({$&amp;lt;Year={"$(#=year(today()))"},Month={"$(#=month(today()))"}&amp;gt;}BacklockQuant),Item,Year,Month)) &amp;gt;
Sum(Aggr(sum({$&amp;lt;Year={"$(#=year(today()))"},Month={"$(#=month(today()))"}&amp;gt;}OnStock),Item,Year,Month)),
//Then
Sum(Aggr(sum({$&amp;lt;Year={"$(#=year(today()))"},Month={"$(#=month(today()))"}&amp;gt;}OnStock),Item,Year,Month)),
//Else
Sum(Aggr(sum({$&amp;lt;Year={"$(#=year(today()))"},Month={"$(#=month(today()))"}&amp;gt;}BacklockQuant),Item,Year,Month))
)
,Item,Year,Month))&lt;/LI-CODE&gt;&lt;P&gt;SS:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GTO_TEST.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/187100iAC9FE62955F61A79/image-size/large?v=v2&amp;amp;px=999" role="button" title="GTO_TEST.png" alt="GTO_TEST.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Feb 2026 06:08:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543890#M109610</guid>
      <dc:creator>BIAKS</dc:creator>
      <dc:date>2026-02-27T06:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543906#M109611</link>
      <description>&lt;P&gt;Your comparing logic is - take the smaller value which is also applied on the total-level because 65 is smaller as 74. Like above hinted the totals doesn't respect the results of the row-level else they calculate their own ones. To get the sum of the rows the aggr() needs to wrapped on the outside of row-level calculation - with the right dimension-context. In a case like yours I would apply the following:&lt;/P&gt;&lt;P&gt;sum(aggr(rangemin(OnStock_Expr, BackLog_Expr), Item))&lt;/P&gt;</description>
      <pubDate>Fri, 27 Feb 2026 14:28:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543906#M109611</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2026-02-27T14:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Total amount wrong calculated</title>
      <link>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543981#M109621</link>
      <description>&lt;P&gt;Thanks a lot Marcus,&lt;/P&gt;&lt;P&gt;but is still note able to get this fixed with rangemin.&lt;/P&gt;&lt;P&gt;=sum(Aggr(&lt;BR /&gt;rangemin(&lt;BR /&gt;Sum(Aggr(sum({$&amp;lt;Year={"$(#=year(today()))"},Month={"$(#=month(today()))"}&amp;gt;}OnStock),Item,Year,Month)),&lt;BR /&gt;Sum(Aggr(sum({$&amp;lt;Year={"$(#=year(today()))"},Month={"$(#=month(today()))"}&amp;gt;}OnStock),Item,Year,Month))&lt;BR /&gt;)&lt;BR /&gt;,Item,Year,Month))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the post above from&amp;nbsp;&lt;SPAN class=""&gt;BIAKS&lt;/SPAN&gt;&amp;nbsp;fixed my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks you very much for your help and the very interesting detailed response!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2026 08:59:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Total-amount-wrong-calculated/m-p/2543981#M109621</guid>
      <dc:creator>Thomas_G</dc:creator>
      <dc:date>2026-03-02T08:59:52Z</dc:date>
    </item>
  </channel>
</rss>

