Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Can anyone please help me with below situation
Filed1, Field2
1, AA;BB
2, AA
3, AA
4, AA
5, AA;BB;CC
6, AA
I need count Filed2 and I get Count(Filed2) = 6 but
I need to get Count(filed2) = 9 (counting BB for 1 and BB and CC for 5 which brings up count from 6 to 9)
Please help me to understand how can we do using Qlik?
Thanks
hi
in your load script
run this
load Field1,
subfield(Field2,';') as Field2
From Table
Thanks for your reply,
In doing so BB and CC will be in a separate filed, how will I get Count(filed2) = 9 ?
Thanks
hi
no, you'll have only two fields Field1 and Field2
but you'll create now rows in the table the table will look like this
Field1,Field2
1,AA
1,BB
2,AA
3,AA
4,AA
5,AA
5,BB
5,CC
6,AA
One solution is..
tab1:
LOAD *, SubStringCount(Field2&';',';') As Cnt
;
LOAD * INLINE [
Field1, Field2
1, AA;BB
2, AA
3, AA
4, AA
5, AA;BB;CC
6, AA
];
Left Join(tab1)
LOAD Sum(Cnt) As Total_Cnt
Resident tab1
;
You can do the count in the script as @Saravanan_Desingh suggests, but I assume that you can use the substringcount straight into the object as well.
=SubStringCount(Field2&';',';')
You have received multiple replies at this point, it would be greatly appreciated if you would return and close out the thread by using the Accept as Solution button on the post(s) that helped you get what you needed. This gives the poster(s) credit for the help, and lets other Members know what worked for you. If you did something different, you can post that and then use the button on that post too. If you have further questions etc., please leave an update post.
Regards,
Brett