Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
alex_202
Contributor II
Contributor II

How to count the values with reg expression in measure by condition?

in my data model, I have column where its value started with specific string pattern + some numbers. I am specifically interested to count the values with specific pattern like 'ABxxxxx'. To do so, I think I can use if condition but I am not getting correct output. Can any one help me with that?

 

This is my example column (col1 is column name) with following values:

 

col1

AO555475
AO561991
AO596493
AO596524
AO596578
AO596586
AT27549
AT2755
AT27552
FO182121
FO18222
FO182276
JA274116
JA274477
JA274484
JA274592

 

I am only interested to count the value started with JA, so I should get 4 as output. This is how I did in my master measure expression:

 

if(ja={ regexparse:{$.col1}, "JA" }, count(distinct ja), skip)

I also tried following:

 

=IF[(col1) Contains string(JA), Return count(distinct)]

 

count(distinct(IF[(col1) Contains string(JA), count, 0]    // my 2nd attempt

If(col1 LIKE '*JA*', count, break)                                  // my 3rd attempt

count(distinct(If(WildMatch(col1, '*JA*'), 'Yes'))             //// my 4th attempt

 

I am not sure my attempt is correct since I am newbie to qlik sense. Can anyone help me how to achieve this?

Labels (4)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Count({<col1={"JA*"}>}Distinct col1)

-Rob

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Count({<col1={"JA*"}>}Distinct col1)

-Rob

alex_202
Contributor II
Contributor II
Author

Thank you @rwunderlich