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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
danielact
Partner - Creator III
Partner - Creator III

Conditional within rank/agg

I have a lot of data on insurance policies. I have a table showing the top 10 policies by premium. Here's my function for the dimension:

=if(aggr(rank(Premium), Year)<11, Policy_Nbr)

I was asked to only show recent policies - let's say in the last year. I have a field which shows when the policy was written, which is called pol_date. Any idea on how I can limit that function only to the last year? I created a variable called vRecentDate which is set to =max(pol_date) - that way when filters are applied, the value of the recet date will update to the data being looked at. But how do I work it into the original function?

3 Replies
sridhar240784
Creator III
Creator III

Wil this help you?

=if(aggr(rank(Sum({<Year = {"$(=Year(Max(pol_date))-1)"}>} Premium)), Year)<11, Policy_Nbr)

If this is not helping you, pl post your sample data.

-Sridhar

danielact
Partner - Creator III
Partner - Creator III
Author

No, that doesn't help. I realized an error in my original script and corrected it (I was summing ALL premium instead of taking only the one year).

I'm attaching an example of it. I want to be able to limit the year to only the latest one - take the max of the dates, and go back one year from it.

sridhar240784
Creator III
Creator III

Hi,

Check out the attached application.

Your Expression should be like below.

aggr(rank(Sum({<UW_Year = {"$(=Max(UW_Year))"}>} Premium)), Contract_Year)

Hope this helps you.

-Sridhar