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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
rob_vander
Creator
Creator

set expression to count highest symbol in the string

Hi All,

I have below data set

load * Inline [
ID,String
1,a:b:c
2,b:c:d
3,a:b
4,b:c]

I want to count the Number of IDs where String contains most symbol ":". I this example, count will 2 (ID=1,2) because both contains more ":"symbol (i.e 2)

I want to do it in expression as I don't have access to script.

Labels (1)
2 Solutions

Accepted Solutions
tresB
Champion III
Champion III

Count({<ID={"=SubStringCount(String, ':')=Max(Total SubStringCount(String, ':'))"}>}ID)

tresesco_0-1722862524944.png

 

View solution in original post

Kushal_Chawda
MVP
MVP

@rob_vander  In this case, only way is to create Primary key column in script using RowNo() function then use it to display count

Count({<Primary_key={"=SubStringCount(String, ':')= $(=Max(SubStringCount(String, ':')))"}>}ID)

 

View solution in original post

4 Replies
tresB
Champion III
Champion III

Count({<ID={"=SubStringCount(String, ':')=Max(Total SubStringCount(String, ':'))"}>}ID)

tresesco_0-1722862524944.png

 

rob_vander
Creator
Creator
Author

@tresB  It's working when we have unique values in ID. Actually I have repeated values for ID, so one ID may have multiple String with different length. How do we change set?

Kushal_Chawda
MVP
MVP

@rob_vander  In this case, only way is to create Primary key column in script using RowNo() function then use it to display count

Count({<Primary_key={"=SubStringCount(String, ':')= $(=Max(SubStringCount(String, ':')))"}>}ID)

 

rob_vander
Creator
Creator
Author

@Kushal_Chawda  luckily I had a primary key in table so didn't create one but thanks for the solution.