Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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 (2)
7 Replies
Highlighted
Partner
Partner

Re: Help ith Count

hi 

in your load script 

run this 

load Field1,

         subfield(Field2,';') as Field2

From Table 

 

Highlighted
Creator
Creator

Re: Help ith Count

Thanks for your reply,

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

 

Thanks

Highlighted
Partner
Partner

Re: Help ith Count

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

Highlighted
Specialist
Specialist

Re: Help ith Count

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
;
Tags (1)
Highlighted
Specialist
Specialist

Re: Help ith Count

commQV69.PNG

Highlighted
Partner
Partner

Re: Help ith Count

You can do the count in the script as @saran7de  suggests, but I assume that you can use the substringcount straight into the object as well. 

=SubStringCount(Field2&';',';')

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
Highlighted
Digital Support
Digital Support

Re: Help ith Count

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.