Suppose I have a table tracking an employees leave at a business. It has the reason for leave, leave type, total days and day range. For this, only the type and total days matter.
I want to be able to see a brief summary, in numbers, of how many of each of the leave types this employee has used. I've attached a sample of the data below as a photo and raw table. For example, this employee has taken 7 days as LSL, so in the coloured table on the right I'd like a way for Excel to count this for me and display 7 in the box.
Image of the table in Excel - also shown below for convenience
Leave Type | Leave Days |
---|---|
A/L | 3 |
A/L | 1 |
A/L | 1 |
A/L | 2 |
A/L | 3 |
A/L | 3 |
DIL | 1 |
A/L | 2 |
A/L | 9 |
A/L | 1 |
A/L | 3 |
DIL | 1 |
LSL | 4 |
DIL | 1 |
DIL | 1 |
A/L | 2 |
SICK | 4 |
A/L | 1 |
DIL | 5 |
DIL | 1 |
LSL | 3 |
I have tried using some VLOOKUP or HLOOKUP but can never seem to get it right!
This is pretty textbook example of sumif.
Put this in your worksheet in H3
and drag down =Sumif(B:B,G3,C:C)
If you wanted to get something more dynamic (and fancy), you could drop this formula in cell G3 and it would dynamically update as you had new items in column b.
=LET(zData,DROP(UNIQUE(TOCOL(B:B,1)),1),HSTACK(zData,SUMIF(B:B,zData,C:C)))