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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
bvmike2001
Contributor III
Contributor III

Flag repeted values in a field at script level

Hello,

i have a simple data set like this:

ID     Value

1     A

2     B

1     A

4     C

5     B

6     D

7     E

8     C

9     D

what best or efficient solution should i use in order to calculate at the script level a new column in witch i want to mark if a Value is repeated or not in next rows and having different IDs?

what i expect is:

ID     Value     Repeated_Flag

1     A          0

2     B          1

1     A          0

4     C          1

5     B          0

6     D          1   

7     E          0    

8     C          0

9     D          0

Thanks!

Mihai

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Something like this:

Temp:

LOAD *, RecNo() as RecNo INLINE [

ID, Value

1 ,    A

2 ,    B

1 ,    A

4 ,    C

5 ,    B

6 ,    D

7 ,    E

8 ,    C

9  ,   D

];

Result:

LOAD

     RecNo,

     ID,

     Value as CheckVal1,

     ID&Value as CheckVal2,

     Value,

     IF(Exists(CheckVal1,Value) and Not Exists(CheckVal2,ID&Value) ,1,0) as Repeated_Flag

RESIDENT

     Temp

ORDER BY

     ID desc

     ;   

    

DROP TABLE Temp;

DROP FIELD CheckVal1, CheckVal2;    


talk is cheap, supply exceeds demand
bvmike2001
Contributor III
Contributor III
Author

Hello Gysbert,

yes your solution works and deliver expected solution.

Meanwhile  i have found myself a solution using inner join on Value and then testing the IDs.

Many Thanks!