Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
School | Group |
Spencer | Corporate |
High Standard | Corporate |
Anointing | Native |
Success | Native |
Classical | Sport Uniform |
Victory | Sport Uniform |
Marvel | Sport Uniform |
Marcon | Sport Uniform |
Yaba | Sport Uniform |
Vikoro | Sport Uniform |
Fountain of Hope | Sport Uniform |
Spencer | Sport Uniform |
High Standard | Sport Uniform |
Anointing | Sport Uniform |
Success | Sport Uniform |
Success | Corporate |
How can I create this Group field from the School field?
Thanks
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;
Just load your second table from a table source or create it in your script using an INLINE LOAD?
No, I have just one table and I need to generate the second from the first
And how do you do the grouping? Based on which rule?
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;
Ok, but isn't this just replicating the second table, I mean, wouldn't it be easier to create and load the second table?
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?
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.
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.