tags:

views:

50

answers:

4

I have written this function that will give me a monthly sum for two columns: one has the date of each order, one has the cost of each order.

=SUMIF($C$1:$C$1000,">="&DATE(2010,6,1),$D$1:$D$1000)-SUMIF($C$1:$C$1000,">="&DATE(2010,7,1),$D$1:$D$1000)

Using data like this:

8/16/10 17:00 7.99
8/16/10 14:25 7.99 
8/15/10 22:42 7.99

I end up with a table like this:

May     998
June 968.28
July 1239.76
August  514.96

However, now I would like to do daily sumas, and using my way, I have to hand edit each row. How can I do this better in Excel?

A: 

If the second row has the same pattern as the first row, you just need edit first row manually, then you position your mouse pointer to the bottom-right corner, in the mean time, press ctrl key to drag the cell down. the pattern should be copied automatically.

Russel Yang
Andrew Johnson
+1  A: 

Use a column to let each date be shown as month number; another column for day number:

      A      B       C         D
   -----  ----- ----------- --------
1     8      6    8/6/2010   12.70
2     8      7    8/7/2010   10.50
3     8      7    8/7/2010    7.10
4     8      9    8/9/2010   10.50
5     8     10   8/10/2010   15.00

The formula for A1 is =Month(C1).
The formula for B1 is =Day(C1)

For Month sums, put the month number next to each month:

      E      F         G     
   -----  ----- -------------  
1     7    July   $1,000,010 
2     8     Aug   $1,200,300 

The formula for G1 is =SumIf($A$1:$A$100, E1, $D$1:$D$100). This is a portable formula; just copy it down.

Total for the day will be be a bit more complicated, but you can probably see how to do it.

Smandoli
+2  A: 

Use pivot tables, it will definitely save you time. If you are using excel 2007+ use tables (structured references) to keep your table dynamic. However if you insist on using functions, go with Smandoli's suggestion. Again, if you are on 2007+ use SUMIFS, it's faster compared to SUMIF.

Niketya
I would like to accept your answer as well, because I think it is also valid. Best I can do is upvote though :)
Andrew Johnson
+1 Yes, this is a great application for pivot tables.
Smandoli
In all honesty, I must add I don't like pivot tables although I use them sometimes. I can't offer any valid reasons for disliking them -- it's probably from trying to use Excel's chart wizards (the early versions, pre-Y2K). Also, I use OpenOffice more than Excel -- it has a pivot-table feature (I believe), but I imagine it is less mature; I stay on the simple paths.
Smandoli
+1  A: 

Following up on Niketya's answer, there's a good explanation of Pivot Tables here: http://peltiertech.com/WordPress/grouping-by-date-in-a-pivot-table/

For Excel 2007 you'd create the Pivot Table, make your Date column a Row Label, your Amount column a value. You'd then right click on one of the row labels (ie a date), right click and select Group. You'd then get the option to group by day, month, etc.

Personally that's the way I'd go.

If you prefer formulae, Smandoli's answer would get you most of the way there. To be able to use Sumif by day, you'd add a column with a formula like:

=DATE(YEAR(C1), MONTH(C1), DAY(C1))

where column C contains your datetimes.

You can then use this in your sumif.

David
Also would like to accept your answer as part of this... upvoted.
Andrew Johnson