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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
MarcelPadu
Contributor
Contributor

Displaying distinct rows based on two columns

Im trying to display rows from the table underneath but only when i have 2 or more C1 fields with the same value but different C2 values.

In this case:

Changes:
Load * inline [
C1 C2
1 1
2 3
2 3
2 4
3 5
3 2
4 12
4 12
6 10
] (delimiter is '\t');

i should only display 

2 3

2 4

5 3 

5 2

i found that using 

=if(Aggr(Count(C1),C1)<>Aggr(Count(C2),C2),C1)

helps me find the fields fast but it only displays 1 value of C2 and i have to check another table to see the values.

 

Labels (1)
1 Solution

Accepted Solutions
jbhappysocks
Creator II
Creator II

=aggr(
if(count(distinct total <C1> C2)>1, C1)
,C2,C1)

Change bold to C2 for 2:nd column

jbhappysocks_0-1675073474623.png

View solution in original post

3 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi there!

I'd aggregate the data in the script and calculate a conditional flag that determines if the data should be displayed or not:

ChangesFlag:

LOAD

     C1,

     IF(C2_Count > 1, 1, 0)   as ChangeFlag

;

LOAD

     C1,

     count(C2) as C2_Count

;

LOAD DISTINCT

     C1, C2, 1 as NoconcatDummy

RESIDENT

     Changes

;

Something like this.

Come to the virtual Masters Summit for Qlik to learn advanced techniques like this one, and many others!

jbhappysocks
Creator II
Creator II

=aggr(
if(count(distinct total <C1> C2)>1, C1)
,C2,C1)

Change bold to C2 for 2:nd column

jbhappysocks_0-1675073474623.png

MarcelPadu
Contributor
Contributor
Author

Yeah it works perfectly, many thanks!