Count with criteria

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
951
Office Version
  1. 365
Hi,

I have the following table:

Book1
AB
1InteractionsPolicy Count
2Customer came to make a complaint and make enquiry on policy 0012455 and A445587.2
3Policyholder made enquiry on policy 9988567 and S4444447.2
4Policyholder made enquiry on policy 9988567 and S4444447 and 5454545A3
5Policyholder made enquiry on policy 9988567/S4444447/5454545A3
6Customer came to make a complaint and make enquiry on policy 00124774and S449987.2
Sheet1


In column A, I have the interactions with customer which also indicates the policy numbers of the customers. Since this interactions are entered manually by the service agent, there could be several possible variations as indicated in column A. Example in row no 6 is not a typo error but it is meant to show an example of the service agent entering the policynumber and the word "and" together as this could also be a possible variation.

In column B , I am trying to count the number of policy numbers mentioned in column A. The correct results are indicated in column B.

Is there a way to use a formula to derive this ? Appreciate all the help.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You can try the below :

Book3
AB
1InteractionsPolicy Count
2Customer came to make a complaint and make enquiry on policy 0012455 and A445587.2
3Policyholder made enquiry on policy 9988567 and S4444447.2
4Policyholder made enquiry on policy 9988567 and S4444447 and 5454545A3
5Policyholder made enquiry on policy 9988567/S4444447/5454545A3
6Customer came to make a complaint and make enquiry on policy 00124774and S449987.2
Sheet1
Cell Formulas
RangeFormula
B2:B6B2=LET(p,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXTAFTER(A2,"policy "),"and",","),".",""),"/",","),LEN(p)-LEN(SUBSTITUTE(p,",",""))+1)
 
Upvote 0
Probably You won't be able to eliminate all possibilities which can be put 'incorrectly'.....

Possible solution as well:

Book1
ABC
1Interactionsexpectedformula
2Customer came to make a complaint and make enquiry on policy 0012455 and A445587.22
3Policyholder made enquiry on policy 9988567 and S4444447.22
4Policyholder made enquiry on policy 9988567 and S4444447 and 5454545A33
5Policyholder made enquiry on policy 9988567/S4444447/5454545A33
6Customer came to make a complaint and make enquiry on policy 00124774and S449987.22
Sheet1
Cell Formulas
RangeFormula
C2:C6C2=COUNTA(LET(xR,TEXTSPLIT(SUBSTITUTE(SUBSTITUTE(A2,".",""),"/"," ")," ",,1),FILTER(xR,ISNUMBER(--(MID(xR,3,1))))))
 
Upvote 0
Hi Sanjeev and Koksek,

Thank you for the solution. Looking at the data, I realized, there is also another variation where the interaction with the customers could also have no policy numbers . Example as below:

Customer came for surrender. Managed to conserve.

Is there any way we could modify the formula to accommodate this scenario as well ? The correct result should be zero for policy count for this scenario.
 
Upvote 0
If you modify the solution provided by @Sanjeev1976 to
Excel Formula:
=IFERROR(LET(p,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXTAFTER(A6,"policy "),"and",","),".",""),"/",","),LEN(p)-LEN(SUBSTITUTE(p,",",""))+1),0)
it should handle that situation.
 
Upvote 0
Hi myall,

Thank you. Just realized that if the word policy is not in the interaction documented by the service staff as below, the formula also returns 0 instead of counting the policy number. Example as below:

Customer came for surrender. Managed to conserve and make PW. 4545445A/5454545A


In the above scenario, the result should be 2 . Appreciate the help.
 
Upvote 0
Hello Kumara,

You need to provide all the different kind of scenarios to get the right help in 1 shot and cannot think of new scenarios every few minutes. The below captures your requirement :
Book4
AB
1InteractionsPolicy Count
2Customer came to make a complaint and make enquiry on policy 0012455 and A445587.2
3Policyholder made enquiry on policy 9988567 and S4444447.2
4Policyholder made enquiry on policy 9988567 and S4444447 and 5454545A3
5Policyholder made enquiry on policy 9988567/S4444447/5454545A3
6Customer came to make a complaint and make enquiry on policy 00124774and S449987.2
7Customer came for surrender. Managed to conserve.0
8Customer came for surrender. Managed to conserve and make PW. 4545445A/5454545A2
Sheet2
Cell Formulas
RangeFormula
B2:B8B2=IFERROR(LET(p,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IFERROR(TEXTAFTER(A2,"policy "),TEXTAFTER(A2,"PW. ")),"and",","),".",""),"/",","),LEN(p)-LEN(SUBSTITUTE(p,",",""))+1),0)
 
Upvote 0
Hi Sanjeev,

My apologies. I have combed through the database and here is all the possible scenarios:

Policy Count Formula.xlsx
ABC
1ScenarioInteractionsPolicy Count
21Customer came to make a complaint and make enquiry on policy 0012455 and A445587.2
32Policyholder made enquiry on policy 9988567 and S4444447.2
43Policyholder made enquiry on policy 9988567 and S4444447 and 5454545A3
54Policyholder made enquiry on policy 9988567/S4444447/5454545A3
65Customer came to make a complaint and make enquiry on policy 00124774and S449987.2
76Customer came for surrender. Managed to conserve and make PW. 4545445A/5454545A2
87Customer came for 3 policy to surrender. Managed to conserve 1 policy and another 2 PW0
98Customer came to surrender 3. Managed to conserve 1 policy and another 2 PW0
109Customer came to surrender 3. Managed to conserve 1 policy and another 2 PW/a444557/45545A2
1110Customer came to surrender 3. Managed to conserve 1 and another 2 PW/a444557/45545A2
Sheet1


Appreciate your help.
 
Upvote 0
You can use the below :
Book4
AB
1InteractionsPolicy Count
2Customer came to make a complaint and make enquiry on policy 0012455 and A445587.2
3Policyholder made enquiry on policy 9988567 and S4444447.2
4Policyholder made enquiry on policy 9988567 and S4444447 and 5454545A3
5Policyholder made enquiry on policy 9988567/S4444447/5454545A3
6Customer came to make a complaint and make enquiry on policy 00124774and S449987.2
7Customer came for surrender. Managed to conserve and make PW. 4545445A/5454545A2
8Customer came for 3 policy to surrender. Managed to conserve 1 policy and another 2 PW0
9Customer came to surrender 3. Managed to conserve 1 policy and another 2 PW0
10Customer came to surrender 3. Managed to conserve 1 policy and another 2 PW/a444557/45545A2
11Customer came to surrender 3. Managed to conserve 1 and another 2 PW/a444557/45545A2
Sheet2
Cell Formulas
RangeFormula
B2:B11B2=SUM(ISNUMBER(--(MID(TEXTSPLIT(SUBSTITUTE(SUBSTITUTE(A2,".",""),"/"," ")," ",,1),3,1)))*1)
 
Upvote 0

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top