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

Grouping and comparing row values to create a flag

I am trying to create a calculated column in load script or in report with the following logic. Here we have 2 sets of conditions because 1. 'selected' might come first or 2. 'discarded' might come first. I unable to build the logic to achieve such functionality. Need some expert advice. Thanks

For each individual , FLAG  'YES' when:

IF the ~<type> (ie. life, tpd) has a ~<status> = discarded,

   IF there is the same ~<type> has a ~<status> = selected, AND

      IF the discarded ~<score> is greater than selected ~<score>, AND

         the ~<sum> is less than the selected ~<sum>

IF the ~<type> (ie. life, tpd) has a ~<status> = selected,

   IF there is the same ~<type> has a ~<status> = discarded, AND

      IF the selected ~<score> is less than discarded ~<score>, AND

         the ~<sum> is greater than the discarded ~<sum>

ELSE 'NO'

   

IDCustomerTypeStatusScoreSum
1alifeselected40$4,000
1 ip
1 tpd
1 lifediscarded50$3,000
2blifediscarded60$2,000
2 trauma
2 lifeselected80$1,000
4cip
4 lifediscarded20
4 lifeselected40
3 Replies
qliksus
Specialist II
Specialist II

Can you explain what you wanted as the expected output ? you explanation is not quite clear

Anonymous
Not applicable
Author

I wanted to create a flag (YES/NO) in my report based on the above logic.

Anonymous
Not applicable
Author

Something like this :

   

IDCustomerTypeStatusScoreSumDiscard Warning
1Alexlifeselected40$4,000Yes
1 ip
1 tpd
1 lifediscarded50$3,000
2Stuartlifediscarded60$2,000No
2 trauma
2 lifeselected80$1,000
4Johnip Yes
4 lifediscarded40$500
4 lifeselected20  $1,000