<?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: Dynamic aggregate value at the row level in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751301#M453621</link>
    <description>&lt;P&gt;A group is not a real field so it can't be used where the expression is expecting a field. I don't think you can have one expression that works with all the fields in the cyclic group. You might want to consider using the data model to help with doing this.&lt;/P&gt;</description>
    <pubDate>Sun, 11 Oct 2020 03:36:17 GMT</pubDate>
    <dc:creator>MikeW</dc:creator>
    <dc:date>2020-10-11T03:36:17Z</dc:date>
    <item>
      <title>Dynamic aggregate value at the row level</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1750244#M453544</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have read many posts, but I can't find the answer. Please help me solve this problem, thanks.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I want to achieve dynamic aggregation at the row level. I have some raw data as attached file. The data has five dimensions (code, group, brand, product, Yearmonth, rolling), and the measurement is value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Calculation Logic:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1. There is a straight table whose dimensions are code and product. When Yearmonth is selected, judge the data of each row, find the largest Yearmonth with value greater than 0, and then summarize value from this month and the previous two months.&lt;/P&gt;&lt;P&gt;2. Then calculate the maximum value of the selected Yearmonth, subtract the maximum Yearmonth of each row, and judge whether it is greater than or equal to 3. If so, the number of months is equal to the result of the subtraction subtract 2.&lt;/P&gt;&lt;P&gt;3. The final calculation result should be the result of step 1 divided by 3 and multiplied by the result of step 2.&lt;/P&gt;&lt;P&gt;My expression :&lt;BR /&gt;=Sum({$&amp;lt;Rolling= {"$(='&amp;gt;=' &amp;amp; Max(Aggr(Max(If(Value&amp;gt;0, Rolling))-2,Code,ProdGroup))) $(='&amp;lt;=' &amp;amp; Max(Aggr(Max(If(Value&amp;gt;0, Rolling)),Code,ProdGroup)))"}&amp;gt;} Value) / 3&lt;BR /&gt;*&amp;nbsp;($(vMaxRolling) - Max(Aggr(Max(If(Value&amp;gt;0, Rolling)),Code,ProdGroup))-2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For example:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="screenshot1.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/41836i851E4F90A12D8AC0/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot1.PNG" alt="screenshot1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The first row of data: Code (6451), product (product1). When Yearmonth is selected from 201810 to 201909, the maximum Yearmonth whose value is greater than 0 is 201906. Summarize the values of 201906 and the previous two months, divide by 3, and multiply by (201909 minus 201906 and then subtract 2). You can also use the rolling value corresponding to Yearmonth to calculate the month.&lt;/P&gt;&lt;P&gt;Expected result: (0 + 0 + 30600) / 3 * (12-9-2) = 10200&lt;/P&gt;&lt;P&gt;Actual result: 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When Yearmonth is selected from 201810 to 201905.&lt;/P&gt;&lt;P&gt;Expected result: (41376 + 0 + 27110) / 3 * (8-4-2) = 45657.3&lt;BR /&gt;Actual Result: 0&lt;/P&gt;&lt;P&gt;Other rows please see the above screenshot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the group dimension is drilled down to group or brand, then it should be calculated by group or brand aggregation.&lt;/P&gt;&lt;P&gt;It would be appreciated if you have any suggestions or solutions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a simple sample as attached.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 18:00:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1750244#M453544</guid>
      <dc:creator>Swang</dc:creator>
      <dc:date>2024-11-16T18:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic aggregate value at the row level</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1750885#M453584</link>
      <description>&lt;P&gt;Any good idea?&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 02:25:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1750885#M453584</guid>
      <dc:creator>Swang</dc:creator>
      <dc:date>2020-10-09T02:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic aggregate value at the row level</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751254#M453615</link>
      <description>&lt;P&gt;DSEEs can't be used here because DSEEs are expanded ignoring table dimensions, so it will be expanded using the global selections.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try something like below. Not sure what you mean by drilling down to group or band though.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SUM(
    IF(
        [Rolling] - AGGR(MAX({&amp;lt;[Value]-={0}&amp;gt;} TOTAL&amp;lt;[Code], [Product]&amp;gt; [Rolling]), [Code], [Product], [Group], [Brand], [Rolling]) &amp;lt;= 0
        AND 
        [Rolling] - AGGR(MAX({&amp;lt;[Value]-={0}&amp;gt;} TOTAL&amp;lt;[Code], [Product]&amp;gt; [Rolling]), [Code], [Product], [Group], [Brand], [Rolling]) &amp;gt;- 3,
        [Value],
        0
    )
) / 3 * RANGEMAX(MAX([Rolling]) - MAX({&amp;lt;[Value]-={0}&amp;gt;}[Rolling]) - 2, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2020 07:47:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751254#M453615</guid>
      <dc:creator>MikeW</dc:creator>
      <dc:date>2020-10-10T07:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic aggregate value at the row level</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751265#M453616</link>
      <description>&lt;P&gt;Thanks for you suggestion. I will try it.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please ignore&amp;nbsp; the description of drilling down to group or band.&amp;nbsp;It's not a problem.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2020 08:57:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751265#M453616</guid>
      <dc:creator>Swang</dc:creator>
      <dc:date>2020-10-10T08:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic aggregate value at the row level</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751270#M453618</link>
      <description>&lt;P&gt;I try this expression and it is OK most of the time, but when I drill down to the Group dimension, one of the rows does not calculate correctly. The correct result is (0+16569+ 66,780)= 83,349, but the actual result is 1,050. Please see the screenshot below for my selections.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="screenshot2.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/42036iD59679CEEA48C9C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot2.PNG" alt="screenshot2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The expression I used is as follows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SUM( 
IF( [Rolling] - AGGR(MAX({&amp;lt;[Value]-={0}&amp;gt;} TOTAL&amp;lt;[Code], [ProdGroup]&amp;gt; [Rolling]), [Code], [ProdGroup], [Rolling]) &amp;lt;= 0

AND [Rolling] - AGGR(MAX({&amp;lt;[Value]-={0}&amp;gt;} TOTAL&amp;lt;[Code], [ProdGroup]&amp;gt; [Rolling]), [Code], [ProdGroup], [Rolling]) &amp;gt;- 3, [Value], 0 
) 
)
/ 3 
* RANGEMAX($(vMaxRolling) - MAX({&amp;lt;[Value]-={0}&amp;gt;}[Rolling]) - 2, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"ProdGroup" is a group dimension(Group/Brand/Product) and "VMaxRolloing" is a variable whose formula is: vMaxRolloing=Max(Rolling).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Suggestions?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2020 09:54:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751270#M453618</guid>
      <dc:creator>Swang</dc:creator>
      <dc:date>2020-10-10T09:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic aggregate value at the row level</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751301#M453621</link>
      <description>&lt;P&gt;A group is not a real field so it can't be used where the expression is expecting a field. I don't think you can have one expression that works with all the fields in the cyclic group. You might want to consider using the data model to help with doing this.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 03:36:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751301#M453621</guid>
      <dc:creator>MikeW</dc:creator>
      <dc:date>2020-10-11T03:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic aggregate value at the row level</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751747#M453639</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Maybe you are right. Thanks for your suggestions.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 02:21:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1751747#M453639</guid>
      <dc:creator>Swang</dc:creator>
      <dc:date>2020-10-13T02:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic aggregate value at the row level</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1752678#M453657</link>
      <description>&lt;P&gt;I fixed the question. I modified the data model and ran the complex calcualtion logic in load script.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 07:23:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-aggregate-value-at-the-row-level/m-p/1752678#M453657</guid>
      <dc:creator>Swang</dc:creator>
      <dc:date>2020-10-15T07:23:53Z</dc:date>
    </item>
  </channel>
</rss>

