# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
cancel
Showing results for
Did you mean:
Partner - Specialist III

## How to find Those id Which fall under two Categories

Hi Experts,

I have data as following:

ID   Col1   col2    Group

1     11       12        A

2     12        12      A

3     13        12      A

4    11        12      B

5   11         12      A

2    11        11      B

3    11         11     B

I requre Output   follows:

ID  who are in both group:

ID   Col1   col2    Group   Final Group

1     11       12        A            A

2     12        12      A            Both

3     13        12      A            Both

4    11        12      B                 B

5   11         12      A                 A

2    11        11      B               Both

3    11         11     B                Both

Thanks,

Arvind Patil

1 Solution

Accepted Solutions
Master III

Hi Arvind,

may be this

Table:
ID Col1 col2 Group
1 11 12 A
2 12 12 A
3 13 12 A
4 11 12 B
5 11 12 A
2 11 11 B
3 11 11 B
]
(delimiter is spaces);
Left Join
LOAD ID,If(Count(DISTINCT Group) > 1,'Both',Only(Group)) as FinalGroup
Resident Table Group By ID
;

Regards,

Antonio

5 Replies
Master III

Hi Arvind,

may be this

Table:
ID Col1 col2 Group
1 11 12 A
2 12 12 A
3 13 12 A
4 11 12 B
5 11 12 A
2 11 11 B
3 11 11 B
]
(delimiter is spaces);
Left Join
LOAD ID,If(Count(DISTINCT Group) > 1,'Both',Only(Group)) as FinalGroup
Resident Table Group By ID
;

Regards,

Antonio

Master

Hi Arvind,

Maybe one of these expressions?

ID Concat(Group,',') if(count(DISTINCT Group)= 1, Group, 'Both')
1AA
2A,BBoth
3A,BBoth
4BB
5AA

Saying Concat(Group,',') rather than 'Both' means there is more flexibility should your data begin to include more groups.

OR you can use calculated dimensions to see things from another point of view.

=Aggr(Concat(Group,','),ID) Concat(DISTINCT ID,',')
A1,5
A,B2,3
B4

=Aggr(if(count(DISTINCT Group)= 1, Group, 'Both'),ID) Concat(DISTINCT ID,',')
A1,5
Both2,3
B4

Cheers

Andrew

Partner - Specialist III
Author

Hi Andrew ,

Thanks,

Arvind Patil

Master

Try:

Data:

ID,   Col1,   col2,    Group

1,     11,       12,        A

2,     12,        12,      A

3,     13,        12,      A

4,    11,        12,      B

5,   11,         12,      A

2,    11,        11,      B

3,    11,         11,     B

];

Table1:

ID,

Concat(DISTINCT Group,',') as Groups

Resident Data Group by ID;

Table1:

ID Groups
1A
5A
2A,B
3A,B
4B

Regards

Andrew

Partner - Specialist III
Author

Hi Antonio,

Thanks for your valuable feedback. It  works for me.

Thanks,

Arvind Patil