When you enter a date in a cell, the sheet displays what you entered. Thus, 3/1/06 is displayed just that way. But the sheet stores this date as a serial number. You can change the format of the cell by setting the formatting to something like "MMM DD, YYYY" and that same date will suddenly display as "Mar 06, 2006". But the serial number will be the same. Remember that.
In my rural market, sales happen slowly. I wanted to show the number of sales per period, but didn't quite know how. I had downloaded three years' worth of sales data from my provider, and had imported it into a spreadsheet. One of the columns was "Last Sale Date." There were 123 sales shown.
"Aha! I can get that thing to display only the year and the quarter!" I thought. Selected the column for Last Sale Date, inserted another column, and labeled it "Quarter." Selected the first cell, and entered "=S2" to pull the date of sale over. Formatted the cell to be "Q YY." Sure enough, I got Q1 06 next to the first cell. Quickly copied it down. Now I've got a whole column showing sales in the same quarter.
So I ran a Pivot Table to aggregate these sales by quarter. Selected a cell underneath the table at about A130, and activated the Pivot Table wizard (It's called a 'data pilot' in OpenOffice Calc.) Dragged the "quarter" column into the Data Fields section, double-clicked it, and set "count" as the aggregating function. Moved "quarter" into the row header section so I'd know what quarter I was looking at the aggregate of. Ran the Pivot Table, and got garbage: 121 lines, all saying the same thing they were in the main table. Only two days had more than one sale recorded on them.
What was happening was that Excel was simply aggregating entries which occurred on the same DAY! (Because the sheet keeps track of dates as serial numbers.) Not the result I wanted at all.
Fortunately, there's a way to make Excel (or Calc) quit messing with the date format. Use the TEXT() function. I set the first cell of "Quarter" to the formula =TEXT(S2, "Q YY"), and copied everything down the column.
This time, the Pivot Table worked. Well, almost. What I got was a pivot table which read:
Q1 04 7
Q1 05 9
Q1 06 15
Q1 07 10
Q2 04 ...
...
Q4 06
Q4 07
Again, not what I wanted at all. I had wanted Q1 04, Q2 04, etc. So I went back and changed the formula to =TEXT(S2, "YY Q"), and copied that down. When I ran the pivot table this time, it gave me the answer I'd been looking for. You get two columns of output. The left column is the quarter, the right is the number of sales. Select'em both, and insert a chart. Here's what it looks like:
Most of you work in more active markets, so you may want to aggregate by month. Just use =TEXT(S2, "YY MMM") to capture the month in which the sale occurred, and use the pivot table to aggregate the sales. You should produce a table which shows you the number of sales in each month. If you're not going back into the previous year, then just use =TEXT(S2, "MMM").
