Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
akash_durai1507
Contributor II
Contributor II

Help Optimizing an expression with AGGR

Sum(Aggr(max( {<GLaccountCode={'121001','117000'}>}If((YearEndDate>=NetDueDate and [Clearing Date]>YearEndDate and Arrears>0) or AROverdue='Overdue',ARAmountLC)
),YearFilter,ARKey))

Above is my expression i use on charts and its very slow when there are no filters.

I'm using an As-of table and when i apply filters inside the if-clause, the amount is duplicated(guessing its due to many-to-many joins) and I'm forced to use Max() inside the AGGR() function.

My data model looks like below,

akash_durai1507_0-1765828964363.png


TIA,

3 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

When you built the link table, did you apply the DISTINCT operator?

-Rob

akash_durai1507
Contributor II
Contributor II
Author

Hi Rob!

Thanks for the reply.

Yes, i did apply distinct operator while loading the link table.

Here is the snapshop of the code,

akash_durai1507_1-1765879974119.png

 

 

Chanty4u
MVP
MVP

Try this in your load script 

AR_Snapshot:

LOAD

    YearEndDate,

    ARKey,

    Max(

        If(

            (YearEndDate>=NetDueDate 

             and [Clearing Date]>YearEndDate 

             and Arrears>0)

            or AROverdue='Overdue',

            ARAmountLC

        )

    ) as ARAmount_AsOf

Resident AsOfTable

Group By YearEndDate, ARKey;