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

counting only when an other field starts with a certain letter

I want to count all the actions where the code starts with a P,

the P is followed by different numbers.

What is incorrect in my expression?

count(distinct if(match(project_actions_code,'P%'),action_id))

1 Solution

Accepted Solutions
alexandros17
Partner - Champion III
Partner - Champion III

Match tells if P is contained in the string, use this expression instead:

count(distinct if(Index(project_actions_code,'P')=1,action_id, null()))


or


count({$ <project_actions_code={'P%'}>}  distinct action_id)


let me know

View solution in original post

6 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Match tells if P is contained in the string, use this expression instead:

count(distinct if(Index(project_actions_code,'P')=1,action_id, null()))


or


count({$ <project_actions_code={'P%'}>}  distinct action_id)


let me know

Not applicable
Author

The code starts with a P or an A followed by numbers.

I only want to count the actions where the code starts with a P, without regard wich numbers follow the P

alexandros17
Partner - Champion III
Partner - Champion III

Ok, what about the code I sent to you?

Not applicable
Author

Replace % by *


count({$ <project_actions_code={'P*'}>}  distinct action_id) is the most efficient,


set analysis is more efficient than if clauses,


cheers

Not applicable
Author

The first expression works!

The second one only gives me zero's.

It solved my problem, thanks!

Not applicable
Author

Unfortunatly the set analysis doesn't work, the if-analysis does work