Countif half

scamsel

New Member
Joined
Apr 2, 2007
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Hi, I am building a simple vacation tracker and in each row are peoples days off, indicated with a letter. For example, a 'P' in a cell means that person a personal day that day. (and i use other letters for other types of days off)

But at the end of the row i'm using countif formula to count if the cell is populated with that letter then to count it. However, i have situations where a person may have taken a partial day off. for example ".5P".

What would be a simple way to have the formula result in 1.5 days off in a scenario as below:

1621546555500.png


many thanks in advance.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
If you used XL2BB to illustrate your example, I could have used more data. With an abbreviated set, see if you can use this:

Book1
ABCDEFGHIJKLMNOP
2MonTueWedThuFriSatSunMonTueWedThuFriSatSunPPTO
3.5PP.25P1.75
4PP2
5PP.5P2.5
Sheet15
Cell Formulas
RangeFormula
P3:P5P3=SUM(1*SUBSTITUTE(IF(LEN(A3:N3)=1,1&A3:N3,A3:N3),"P",""))
 
Upvote 0
@kweaver
I don't think that you have taken account of ..
(and i use other letters for other types of days off)

@scamsel
I'm wondering if this is it? Are we just trying to evaluate the "P" days?

21 05 21.xlsm
ABCDEFGHIJKLMNOP
2MonTueWedThuFriSatSunMonTueWedThuFriSatSunPPTO
3SH.5PP.25P1.75
4P.5HP2
5PP.5P2.5
6PPPPPPPPP9
Sheet2 (2)
Cell Formulas
RangeFormula
P3:P6P3=SUM(SUBSTITUTE(FILTER(A3:N3,RIGHT(A3:N3,1)="P"),"P",0)+0)+COUNTIF(A3:N3,"P")
 
Upvote 0
@kweaver
I don't think that you have taken account of ..


@scamsel
I'm wondering if this is it? Are we just trying to evaluate the "P" days?

21 05 21.xlsm
ABCDEFGHIJKLMNOP
2MonTueWedThuFriSatSunMonTueWedThuFriSatSunPPTO
3SH.5PP.25P1.75
4P.5HP2
5PP.5P2.5
6PPPPPPPPP9
Sheet2 (2)
Cell Formulas
RangeFormula
P3:P6P3=SUM(SUBSTITUTE(FILTER(A3:N3,RIGHT(A3:N3,1)="P"),"P",0)+0)+COUNTIF(A3:N3,"P")
You're right, Peter...I was just addressing the P.
 
Upvote 0
This is amazing thank yall. kweeaver, sorry about not posting it via XL2BB. and Peter you are right, i am using different letters so that works! thanks a lot. i do get a #calc! error on some rows with no letters, is the best way to correct that with a iferror in front of the formula?
 
Upvote 0
You could wrap an "IFERROR" around Peter's solution.
 
Upvote 0
Rather than using iferror, filter has it's own error handling so you can use this tweak to Peter's formula
Excel Formula:
=SUM(SUBSTITUTE(FILTER(A3:N3,RIGHT(A3:N3,1)="P",0),"P",0)+0)+COUNTIF(A3:N3,"P")
 
Upvote 0
Rather than using iferror, filter has it's own error handling so you can use this tweak to Peter's formula
Excel Formula:
=SUM(SUBSTITUTE(FILTER(A3:N3,RIGHT(A3:N3,1)="P",0),"P",0)+0)+COUNTIF(A3:N3,"P")

If somebody happened to enter "1P" instead of just "P" for a full day off, that would give an incorrect result, as would my original suggestion. If that was possible then this alternative may be safer
Excel Formula:
=SUM(IF(RIGHT(A3:N3,1)="P",SUBSTITUTE(A3:N3,"P",IF(A3:N3="P",1,""))+0))

.. or, assuming any non-blank cells in the range contain a letter code
Excel Formula:
=SUM(IFERROR(SUBSTITUTE(A3:N3,"P",IF(A3:N3="P",1,""))+0,0))
 
Upvote 0

Forum statistics

Threads
1,214,940
Messages
6,122,361
Members
449,080
Latest member
Armadillos

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