COUNTIF - more than one condition

G

Gary

Hi All,

I have to count Casual Leaves, Sick Leaves, Privilege Leaves and Unscheduled
Leaves for an employee. In the attendance sheet, they're marked as CL, SL,
PL, UL.

Now how do I get a count of all the leaves with just one formula. Right now
I am using this.
=COUNTIF(A2:Z2,"CL")+COUNTIF(A2:Z2,"SL")+COUNTIF(A2:Z2,"PL")+COUNTIF(A2:Z2,"UL")

Is there an easier way? like multiple conditions with just one COUNTIF?

Thanks
Gary.
 
D

Duke Carey

ASSUMING (big assumption), that you only want to count the entries where the
second letter is an L, this is an arrya formula that you enter by pressing
CTRL-SHIFT-ENTER

=SUMPRODUCT(--(MID(A2:Z2,2,1)="L")
 
G

Gary

hey peo. that worked.

a little more help. now if I also want to add half day which is mentioned as
H/D..but I dont want to count it as 1, I want to count it as .5

so if there is one CL and one H/D, the total should be 1.5

any idea?
 
P

Peo Sjoblom

I would add a separate countif

=SUM(COUNTIF(A2:Z2,{"CL";"PL";"SL";"UL"}))+(COUNTIF(A2:Z2,"H/D")/2)


--
Regards,

Peo Sjoblom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top