Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
rob_vander
Contributor III
Contributor III

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
tresesco
MVP
MVP

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

tresesco_0-1722862524944.png

 

View solution in original post

Kushal_Chawda

@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
tresesco
MVP
MVP

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

tresesco_0-1722862524944.png

 

rob_vander
Contributor III
Contributor III
Author

@tresesco  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

@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
Contributor III
Contributor III
Author

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