<?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: YTD with aggregation in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/YTD-with-aggregation/m-p/2415157#M95030</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/175018"&gt;@Carlijn&lt;/a&gt;&amp;nbsp;What is the formulae used for&amp;nbsp;&lt;SPAN&gt;denominator?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2024 05:40:18 GMT</pubDate>
    <dc:creator>Anil_Babu_Samineni</dc:creator>
    <dc:date>2024-02-06T05:40:18Z</dc:date>
    <item>
      <title>YTD with aggregation</title>
      <link>https://community.qlik.com/t5/App-Development/YTD-with-aggregation/m-p/2414960#M95009</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to create a YTD average amount spend per receipt, where I divide a sum of amount by the number of receipts. Condition in de denominator is to only take into account the receipts with total amount &amp;gt;0, a receipt can have multiple lines with products.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's my simplified denominator to calculate number of receipts with amount&amp;nbsp; &amp;gt;0:&lt;/P&gt;
&lt;P&gt;sum(if(aggr(Sum({$&amp;lt;Year, Month, Week, Day, Date = {"&amp;gt;=$(=Date(yearstart(max(Date)),'DD-MM-YYYY'))&amp;lt;=$(=max(Date)),'DD-MM-YYYY'))"}&amp;gt;}[Amount]) , ReceiptId)&amp;gt;0,1,0))&lt;/P&gt;
&lt;P&gt;When I filter a specific date, say 27-01-2024, then my filters become &amp;gt;=01-01-2024&amp;lt;=27-01-2024, which is ok. Problem however, is that the sum of the aggregation is equal to the number of ReceiptIds with amount &amp;gt;0 on exactly 27-01-2024. When I turn the if statement into a dimension in a table with date and receiptid, it works perfectly, it puts a 1 when amount &amp;gt; 0 and 0 when it's &amp;lt;= 0 for all dates between 01-01 and 27-01. However, when I turn it into a measure with sum(), suddenly only 27-01-2024 is taken into account.&lt;/P&gt;
&lt;P&gt;Currently my average spend per receipt is enormous as it calculates the total amount for 01-01-2024 until 27-01-2024 divided by only the number of receipts of 27-01-2024.&lt;/P&gt;
&lt;P&gt;Can anyone help me with what I'm doing wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2024 15:32:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/YTD-with-aggregation/m-p/2414960#M95009</guid>
      <dc:creator>Carlijn</dc:creator>
      <dc:date>2024-02-05T15:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: YTD with aggregation</title>
      <link>https://community.qlik.com/t5/App-Development/YTD-with-aggregation/m-p/2415157#M95030</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/175018"&gt;@Carlijn&lt;/a&gt;&amp;nbsp;What is the formulae used for&amp;nbsp;&lt;SPAN&gt;denominator?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 05:40:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/YTD-with-aggregation/m-p/2415157#M95030</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2024-02-06T05:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: YTD with aggregation</title>
      <link>https://community.qlik.com/t5/App-Development/YTD-with-aggregation/m-p/2415367#M95050</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/5533"&gt;@Anil_Babu_Samineni&lt;/a&gt;&amp;nbsp;The formula I mentioned is for the denominator. For the numerator it is:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sum({$&amp;lt;Year, Month, Week, Day, Date = {"&amp;gt;=$(=Date(yearstart(max(Date)),'DD-MM-YYYY'))&amp;lt;=$(=max(Date)),'DD-MM-YYYY'))"}&amp;gt;}[Amount]).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So In total:&lt;/P&gt;
&lt;P&gt;Sum({$&amp;lt;Year, Month, Week, Day, Date = {"&amp;gt;=$(=Date(yearstart(max(Date)),'DD-MM-YYYY'))&amp;lt;=$(=max(Date)),'DD-MM-YYYY'))"}&amp;gt;}[Amount]).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;sum(if(aggr(Sum({$&amp;lt;Year, Month, Week, Day, Date = {"&amp;gt;=$(=Date(yearstart(max(Date)),'DD-MM-YYYY'))&amp;lt;=$(=max(Date)),'DD-MM-YYYY'))"}&amp;gt;}[Amount]) , ReceiptId)&amp;gt;0,1,0)).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I use more fields in my set expressions (specific types and departments) but these would be in both my numerator and denominator so I excluded them here for simplicity&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 11:13:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/YTD-with-aggregation/m-p/2415367#M95050</guid>
      <dc:creator>Carlijn</dc:creator>
      <dc:date>2024-02-06T11:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: YTD with aggregation</title>
      <link>https://community.qlik.com/t5/App-Development/YTD-with-aggregation/m-p/2415434#M95070</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/175018"&gt;@Carlijn&lt;/a&gt;&amp;nbsp;I am trying to understand the data, You said the condition working as it should with dimension (With aggr()) and whereas you have moved the same to expression and it is not working?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we have some scramble data to demonstrate the same.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 13:04:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/YTD-with-aggregation/m-p/2415434#M95070</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2024-02-06T13:04:48Z</dc:date>
    </item>
  </channel>
</rss>

