Time and money in Excel formulas- aka “why is it doing that?”

I use timings in worksheets alongside other key data, for example, in a project sheet, I have lists of individual tasks, with time started, time ended, total time taken, and then cost based on time taken multiplied by charge etc.

So when I want to calculate a mixture of times multiplied by costs, I get an “argh” moment, the figure doesn’t make sense.  I want to know why is it doing that, and what can I do to fix it.

To tackle this problem, I created a simple example worksheet…I want to put a costing on the time taken to complete a task. I don’t want to include time taken for breaks for other work or a cuppa, so the project cost reflects only the work completed. So I use a start and finish time, calculating the difference between them for the total time.  This result is shown in hours and minutes.

The difficulty is, that I need to multiply time by cost.  In Excel, dates and times are shown as you expect them to look but they are stored and treated as numbers. So when I multiply the time taken in cell F2 by the cost in £ in G2, I get 01.41 which isn’t what I want.

excel-times-multiplied-by-cost-formula-not-working
“I want to work out the time taken multiplied by the cost per hour…but why is Excel doing that? I don’t get it”

So how do I get Excel to show 2 hours and 58 minutes multiplied by the cost of £8.66 per hour? I would expect the cost to be close to 3 x £8.66 = £25.98.

I need to convert the time taken into a number that makes sense for Excel.   What I need to do is add *24 to the formula so Excel can “understand” what I mean.

My old formula was =F2*G2, but that made no sense to Excel and it gave me a figure that made no sense.  So now my revised  formula is =F2*G2*24

excel-times-multiplied-by-cost-results
Correct results achieved by amending the formula with a *24

 

I can then copy this formula down my column H and get the cost per hour for each project task.

Mystery solved.

 

 

 

Using COUNTIFS with Excel 2003

Excel 2007 introduced the function COUNTIFS to count cells based on multiple criteria.

For example suppose you wish to count how many times the client Fowler buys more than 250 shares. The answer for tha data below turns out to be 2 using the Countifs function entered in B13.

Similarly for Owen the result turns out to be 1. 

 

 

 

 

 

 

 

 

 

Even though COUNTIFS is not availailable with Excel 2003 there is an alternative way to perform the same calculation using the SUMPRODUCT array formula.

The formula

 =SUMPRODUCT(–(A2:A11=”Fowler”),–(C2:C11>=250))

typed into C13 produces the same result. The mysterious looking — operator calculates if true or false for each of the cells in the range A2:A11 returning 1 if true and 0 if false. The same goes for the range C2:C11 and the Sumproduct array function sums all the true, true (1*1) combinations.

Note – To show how — works try typing –(A2:A11=”Fowler”) into a cell followed by Ctrl+Shift+Enter. This convets the formula into the array formula {=(A2:A11=”Fowler”)}