Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikuser222
Creator
Creator

Help ith Count

 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

 

Labels (1)
7 Replies
lironbaram
Partner - Master III
Partner - Master III

hi 

in your load script 

run this 

load Field1,

         subfield(Field2,';') as Field2

From Table 

 

qlikuser222
Creator
Creator
Author

Thanks for your reply,

In doing so BB and CC will be in a separate filed, how will I get Count(filed2) = 9 ?

 

Thanks

lironbaram
Partner - Master III
Partner - Master III

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

Saravanan_Desingh

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
;
Saravanan_Desingh

commQV69.PNG

Vegar
MVP
MVP

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&';',';')

Brett_Bleess
Former Employee
Former Employee

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

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.