Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Nagaraju_KCS
Specialist III
Specialist III

Count

Hello Experts,

I have two tables and after some transformations my data looks like below

qv_testing_2-1685970405010.png

Here scenario is, I have to split and count the data Covered field and that should be associated with countries with first table.

Let say If I take count of regions

USA - we have 4 values, but one value is not associated with USA (so count should be 3)

NZ- count should be 2

Region Covered Count
USA USA1,USA3,USA4,NZ1 3
NZ NZ1,NZ2 2

 

@marcus_sommer, @Kushal_Chawda, @MarcoWedel, @tresB  - can you please take a look 

Thanks in Advance!

Labels (1)
2 Solutions

Accepted Solutions
Kushal_Chawda
MVP
MVP

@Nagaraju_KCS  try below expression. Assuming both tables are connected on Region and Covered is comma seprated field already available in the table.

=Count(distinct {<region_id ={"=index(Covered,region_id)"}>}region_id)

 

View solution in original post

MarcoWedel
MVP
MVP

You could also use expressions like

-Sum(Covered like '*'&Region_ID&'*')

or

Sum(Sign(Index(Covered,Region_ID)))

 

To avoid false positive matches for Covered values containing Region_IDs as substring (e.g. "USA1" <-> "USA11" ), you could extend the expressions to something like:

-Sum(','&Covered&',' like '*,'&Region_ID&',*')

or in the case of Kushal's solution

Count(DISTINCT {<Region_ID ={"=Index(','&Covered&',',','&Region_ID&',')"}>} Region_ID)

 

 

 

View solution in original post

3 Replies
Kushal_Chawda
MVP
MVP

@Nagaraju_KCS  try below expression. Assuming both tables are connected on Region and Covered is comma seprated field already available in the table.

=Count(distinct {<region_id ={"=index(Covered,region_id)"}>}region_id)

 

tresB
Champion III
Champion III

May be using substringcount(), like:

tresesco_0-1686026337525.png

 

MarcoWedel
MVP
MVP

You could also use expressions like

-Sum(Covered like '*'&Region_ID&'*')

or

Sum(Sign(Index(Covered,Region_ID)))

 

To avoid false positive matches for Covered values containing Region_IDs as substring (e.g. "USA1" <-> "USA11" ), you could extend the expressions to something like:

-Sum(','&Covered&',' like '*,'&Region_ID&',*')

or in the case of Kushal's solution

Count(DISTINCT {<Region_ID ={"=Index(','&Covered&',',','&Region_ID&',')"}>} Region_ID)