Qlik Community

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 
Search instead for 
Did you mean: 
arvind_patil
Partner - Specialist III
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

Other Column (Col1  , col2 )Need Not Consider  Please Help me .

Thanks,

Arvind Patil

1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

Hi Arvind,

may be this

Table:
LOAD * Inline [
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

View solution in original post

5 Replies
antoniotiman
Master III
Master III

Hi Arvind,

may be this

Table:
LOAD * Inline [
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

effinty2112
Master
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

arvind_patil
Partner - Specialist III
Partner - Specialist III
Author

Hi Andrew ,

Thanks for your reply  but I want it in script level.

Thanks,

Arvind Patil

effinty2112
Master
Master

Try:

Data:

LOAD * INLINE [

    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:

LOAD

ID,

Concat(DISTINCT Group,',') as Groups

Resident Data Group by ID;

Table1:

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

Regards

Andrew

arvind_patil
Partner - Specialist III
Partner - Specialist III
Author

Hi Antonio,

Thanks for your valuable feedback. It  works for me.

Thanks,

Arvind Patil