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

How to get distinct values

Hi,

I have two columns with repeated values:


  F1, F2

    1, a

    2, f

    2, aaaa

    3, b

    4, bb

    5, c

    5, c

    5, c

and how can i get the result shown below:

  F1, F2

    1, a

    2, f

    3, b

    4, bb

    5, c

1 Solution

Accepted Solutions
MarcoWedel

Hi,

another solution could be:


QlikCommunity_Thread_251320_Pic1.JPG

LOAD * INLINE [

    F1, F2

    1, a

    2, f

    2, aaaa

    3, b

    4, bb

    5, c

    5, c

    5, c

] Where not Exists (F1);

hope this helps

regards

Marco

View solution in original post

8 Replies
avinashelite

masismykola
Partner - Contributor III
Partner - Contributor III

Hi,¨

after Load statement write Distinct. This will get you only unique records.

Please mark as answered.

Thank you.

Anonymous
Not applicable
Author

Hi Avinash,

I tried your solution, but am missing something.

Load * inline [F1, F2

    1, a

    2, f

    2, aaaa

    3, b

    4, bb

    5, c

    5, c

    5, c];

  

    load2:

    NoConcatenate

load F1,

firstsortedvalue(F2,F1) as f2 Resident Load

group by F1;

Drop table Load;

It doesnt work. Can you please tell me where i am doing it wrong??

aarkay29
Specialist
Specialist

Try this:

Table:

LOAD * INLINE [

F1, F2

    1, a

    2, f

    2, aaaa

    3, b

    4, bb

    5, c

    5, c

    5, c

   

];

Load 

  F1,

  FirstValue(F2)

Resident

  Table

Group by

  F1;

Drop Table

  Table;

maxgro
MVP
MVP

source:

LOAD *, rowno() as r INLINE [

  F1, F2

    1, a

    2, f

    2, aaaa

    3, b

    4, bb

    5, c

    5, c

    5, c

    ];

   

final:

NOCONCATENATE LOAD

  F1, F2

RESIDENT source

WHERE F1 <> Peek('F1')

ORDER BY r

;

DROP TABLE source;

MarcoWedel

Hi,

another solution could be:


QlikCommunity_Thread_251320_Pic1.JPG

LOAD * INLINE [

    F1, F2

    1, a

    2, f

    2, aaaa

    3, b

    4, bb

    5, c

    5, c

    5, c

] Where not Exists (F1);

hope this helps

regards

Marco

Anonymous
Not applicable
Author

Your solution worked for me!!!!

Anonymous
Not applicable
Author

Thank you Marco.

worked!!