Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Grouping in section

Hello,

I wanna group this schools into Groups.    

School
Spencer
High Standard
Anointing
Success
Classical
Victory
Marvel
Marcon
Yaba
Vik
Fountain of Hope

Some have double group means they are associated to both. Something like this

   

SchoolGroup
SpencerCorporate
High StandardCorporate
AnointingNative
SuccessNative
ClassicalSport Uniform
VictorySport Uniform
MarvelSport Uniform
MarconSport Uniform
YabaSport Uniform
VikoroSport Uniform
Fountain of HopeSport Uniform
SpencerSport Uniform
High StandardSport Uniform
AnointingSport Uniform
SuccessSport Uniform
SuccessCorporate

How can I create this Group field from the School field?

Thanks

1 Solution

Accepted Solutions
Kushal_Chawda

try this

Data:
LOAD School,
if(Match(School,'Anointing','Classical','Fountain of Hope','High Standard','Marcon','Marvel','Spencer','Success','Victory','Vikoro','Yaba'),'Sport Uniform') as Group
FROM
[https://community.qlik.com/thread/211813]
(
html, codepage is 1252, embedded labels, table is @2);

LOAD School,
if(Match(School,'High Standard','Spencer','Success'),'Corporate') as Group
FROM
[https://community.qlik.com/thread/211813]
(
html, codepage is 1252, embedded labels, table is @2);

LOAD School,
if(Match(School,'Anointing','Success'),'Native') as Group
FROM
[https://community.qlik.com/thread/211813]
(
html, codepage is 1252, embedded labels, table is @2);

Final:
NoConcatenate
LOAD *
Resident Data
where not IsNull(Group) ;

DROP Table Data;

View solution in original post

8 Replies
swuehl
MVP
MVP

Just load your second table from a table source or create it in your script using an INLINE LOAD?

Not applicable
Author

No, I have just one table and I need to generate the second from the first

swuehl
MVP
MVP

And how do you do the grouping? Based on which rule?

Kushal_Chawda

try this

Data:
LOAD School,
if(Match(School,'Anointing','Classical','Fountain of Hope','High Standard','Marcon','Marvel','Spencer','Success','Victory','Vikoro','Yaba'),'Sport Uniform') as Group
FROM
[https://community.qlik.com/thread/211813]
(
html, codepage is 1252, embedded labels, table is @2);

LOAD School,
if(Match(School,'High Standard','Spencer','Success'),'Corporate') as Group
FROM
[https://community.qlik.com/thread/211813]
(
html, codepage is 1252, embedded labels, table is @2);

LOAD School,
if(Match(School,'Anointing','Success'),'Native') as Group
FROM
[https://community.qlik.com/thread/211813]
(
html, codepage is 1252, embedded labels, table is @2);

Final:
NoConcatenate
LOAD *
Resident Data
where not IsNull(Group) ;

DROP Table Data;

swuehl
MVP
MVP

Ok, but isn't this just replicating the second table, I mean, wouldn't it be easier to create and load the second table?

Not applicable
Author

See the first school (Spencer) is grouped under (Corporate and Sport Uniform) so Spencer will be associated to these two. Same for others, some are assigned under the 3 groups. clear?

swuehl
MVP
MVP

Yes, clear. But if there isn't rule to link your schools to groups, I think you would need to provide a table:

Data:

LOAD Group, Subfield(Schools,'|') as School INLINE [

Group,Schools

Sport Uniform, Anointing|Classical|Fountain of Hope|High Standard|Marcon|Marvel|Spencer|Success|Victory|Vikoro|Yaba

Corporate, High Standard|Spencer|Success

Native, Anointing|Success

];

This table should  link to your table containing the school facts by key field School. Use Group to group your data.

swuehl
MVP
MVP

Seems you found your solution, though IMHO, it's not generating the second table from the first.

It uses the information from the second table to recreate itself.