<?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 Aggr, Max and complex if statement in one expression? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Aggr-Max-and-complex-if-statement-in-one-expression/m-p/1520431#M37240</link>
    <description>&lt;P&gt;Hello, guys I have been strugling to turn the following requirement into an expression in qlik sense.&lt;/P&gt;&lt;P&gt;I have to calculate the days that a customer is in delay( i got this),&lt;/P&gt;&lt;P&gt;and if the customer has 1 or more loans, all loans except &lt;STRONG&gt;closed&lt;/STRONG&gt; ones should be reported with the maximum delay that all loans of the client has.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if a customer has 2 open loans, 1 with 50 days in delay and the second with 70 days in delay, both should be reported with 70.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;But if the customer has 2 loans, 1 open and 1 closed, it has to take only the amount from the open loan.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following fields:&amp;nbsp;&lt;/P&gt;&lt;P&gt;daysprincipal- amount to be paid&lt;/P&gt;&lt;P&gt;pdsum- amount paid&amp;nbsp;&lt;/P&gt;&lt;P&gt;EndDate- Date chosen by the client&lt;/P&gt;&lt;P&gt;daysdate- the last payment date&lt;/P&gt;&lt;P&gt;client_pin - client id.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So I have to calculate, the maximum days in delay for each client. which works with the following formula:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;max(aggr(nodistinct max(if(daysprincipal-pdsum&amp;gt;0.01,EndDate-daysdate)),client_pin))&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;This formula gives me for each loan, the maximum days in delay, grouped for each client. So if a client has 2 loans, both loans will appear with the same days in delay.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But,&amp;nbsp; now I have a different problem, I have to exclude loans, that are closed from this aggregation.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am checking if the loan is closed with the following formula :&amp;nbsp;&lt;/P&gt;&lt;P&gt;FirstSortedValue(status,-loanstatusid)&amp;lt;&amp;gt;'closed' ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;this gives me all statuses, that the last sorted status is 'closed' but when&amp;nbsp; I include it in the if statement, it doesn't return values..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to Re-Write the expression, so as to NOT calculate closed loans inside the AGGR?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 07:03:21 GMT</pubDate>
    <dc:creator>tomovangel</dc:creator>
    <dc:date>2024-11-16T07:03:21Z</dc:date>
    <item>
      <title>Aggr, Max and complex if statement in one expression?</title>
      <link>https://community.qlik.com/t5/App-Development/Aggr-Max-and-complex-if-statement-in-one-expression/m-p/1520431#M37240</link>
      <description>&lt;P&gt;Hello, guys I have been strugling to turn the following requirement into an expression in qlik sense.&lt;/P&gt;&lt;P&gt;I have to calculate the days that a customer is in delay( i got this),&lt;/P&gt;&lt;P&gt;and if the customer has 1 or more loans, all loans except &lt;STRONG&gt;closed&lt;/STRONG&gt; ones should be reported with the maximum delay that all loans of the client has.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if a customer has 2 open loans, 1 with 50 days in delay and the second with 70 days in delay, both should be reported with 70.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;But if the customer has 2 loans, 1 open and 1 closed, it has to take only the amount from the open loan.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following fields:&amp;nbsp;&lt;/P&gt;&lt;P&gt;daysprincipal- amount to be paid&lt;/P&gt;&lt;P&gt;pdsum- amount paid&amp;nbsp;&lt;/P&gt;&lt;P&gt;EndDate- Date chosen by the client&lt;/P&gt;&lt;P&gt;daysdate- the last payment date&lt;/P&gt;&lt;P&gt;client_pin - client id.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So I have to calculate, the maximum days in delay for each client. which works with the following formula:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;max(aggr(nodistinct max(if(daysprincipal-pdsum&amp;gt;0.01,EndDate-daysdate)),client_pin))&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;This formula gives me for each loan, the maximum days in delay, grouped for each client. So if a client has 2 loans, both loans will appear with the same days in delay.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But,&amp;nbsp; now I have a different problem, I have to exclude loans, that are closed from this aggregation.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am checking if the loan is closed with the following formula :&amp;nbsp;&lt;/P&gt;&lt;P&gt;FirstSortedValue(status,-loanstatusid)&amp;lt;&amp;gt;'closed' ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;this gives me all statuses, that the last sorted status is 'closed' but when&amp;nbsp; I include it in the if statement, it doesn't return values..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to Re-Write the expression, so as to NOT calculate closed loans inside the AGGR?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 07:03:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Aggr-Max-and-complex-if-statement-in-one-expression/m-p/1520431#M37240</guid>
      <dc:creator>tomovangel</dc:creator>
      <dc:date>2024-11-16T07:03:21Z</dc:date>
    </item>
  </channel>
</rss>

