Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I am looking for a solution to concatenate strings from a field as follows:
Say my source data is
sample_table:
load * inline [
Email | department
abc@test.com | IT
abc@test.com | HR
def@test.com | HR
lmn@test.com | IT ];
I would like to create a loop where for instances of repeat emails I concatenate the string, something like department(iterno()-1 &',' & department(iterno()) so that my end table would look like:
Email | department
abc@test.com | IT, HR
def@test.com | HR
lmn@test.com | IT
I am relatively new to working with Qlik Sense, I understand I need to define some variables here but am lost how to do so.
Any help appreciated!
You need no loop else you could aggregate the strings with concat().
- Marcus
Hi @SA_VO
Please check below ,it might help.
tab1:
load * inline [
Email ,department
abc@test.com , IT
abc@test.com , HR
def@test.com , HR
lmn@test.com , IT
lmn1@test.com , IT
lmn1@test.com , Sales
lmn1@test.com , Marketing] ;
NoConcatenate
tab2:
load Email,Concat(department,',') as department Resident tab1 group by Email;
drop Table tab1;
Exit Script;
You need no loop else you could aggregate the strings with concat().
- Marcus
Hi @SA_VO
Please check below ,it might help.
tab1:
load * inline [
Email ,department
abc@test.com , IT
abc@test.com , HR
def@test.com , HR
lmn@test.com , IT
lmn1@test.com , IT
lmn1@test.com , Sales
lmn1@test.com , Marketing] ;
NoConcatenate
tab2:
load Email,Concat(department,',') as department Resident tab1 group by Email;
drop Table tab1;
Exit Script;
I understand my mistake, I completely misinterpreted what the concat() function does.
Both solutions are correct, thank you!