Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
pra_kale
Creator III
Creator III

Sample Data Based on Condition

Hi,

I have attached one sample file. From this file for each policies i want 5 such members which are having maximum Sum Assured.

Below given is the required out_put...

 

Policy_NoStatusMember_NoSumAssured
123456RD23457000
123456IF12457000
123456IF12356000
123456DH12232000
123456IF222231000
2365554RD32194000
2365554IF33390000
2365554RD12387000
2365554IF12487000
2365554DH22285000
146789IF101100000
146789IF104100000
146789IF10399999
146789IF10684756
146789IF10256897

Please help to get the desired result.

Thanks in Advance.

13 Replies
marcus_sommer

Try it with changing the sort-order:

load *, if(Policy_No = previous(Policy_No), peek('MaxFlag') + 1, 1) as MaxFlag

resident Source order by Policy_No, SumAssured desc;

- Marcus

pra_kale
Creator III
Creator III
Author

Hi,

Marcus You are too good...It is working fine.

Just want to ask one thing whether it is possible to do this completely at back-end. Means without creating Calculated Dimension and expression. So at end of the script we will just use STORE command and required data get's stored.

Thanks Once Again for your Help...

marcus_sommer

You could try this:

export:

load * where MaxFlag < 6;

load *, if(Policy_No = previous(Policy_No), peek('MaxFlag') + 1, 1) as MaxFlag

resident Source order by Policy_No, SumAssured desc;

store export into export.qvd (qvd);

- Marcus

pra_kale
Creator III
Creator III
Author

Thanks Marcus...It is working fine.. Great.