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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Newbie_QLIK
Contributor III
Contributor III

Qlik Sense Script - removing duplicates based on priority field

Hi Qlik Sense Community,

Hope this question finds you well.

I need your help to identify the the specific error and solution. The error message I get is :"Invalid expression" for HighestPriorityFlag in my codes written below.

 

For your context, I have defined my definition of duplicates:

if ID and DT_INTERVENTION are the same in other rows, then they are duplicates (highlighted in ythe screenshot below). The error occured when I tried to add a column for row_flag (red column in the screenshot)

Newbie_QLIK_0-1726155530869.png

The followings are my codes. Could you kindly let me know why it does not work?

Thank you so much in advance!

//Remove duplicates and keep the first row of sorted priority
HighestPriorityFlag:
LOAD
*,
If(priority = FirstSortedValue(priority, [ID]&[DT_INTERVENTION]), 'Keep', 'Remove') AS row_flag
RESIDENT OriginalDataWithPriority
GROUP BY [ID], [DT_INTERVENTION], priority;

FinalData:
NOCONCATENATE
LOAD *
RESIDENT HighestPriorityFlag
WHERE row_flag = 'Keep';

Labels (6)
1 Solution

Accepted Solutions
Kushal_Chawda

@Newbie_QLIK  Instead of load * include required field and same field should be there in group by

View solution in original post

2 Replies
Kushal_Chawda

@Newbie_QLIK  Instead of load * include required field and same field should be there in group by

Newbie_QLIK
Contributor III
Contributor III
Author

Hi Kushal,

Thank you for your quick reply!

YES, you are right, I tested with your suggestion, and the expression error is gone!

May I ask the logic behind of it?

Thank you so much!

Best,

Newbie