Today we're going to address methods to accomplish these tasks:
#1 - In a cell or cells, how do I show only the month in a year? Let's Use "1/1/2014":
- =Text([cell reference with date value],"mmm") = Jan
- "m" = 1
- "mm" = 01
- "mmm" = Jan
- "mmmm" = January
- =Month([cell reference with date value])
- This will give the number of the month = 1]
- Right-click on column with the dates > Format cells > Number Tab > Custom > Type = "mmm" (use one of the above)
#2 - In a pivot table, how do I group the dates by month in the row category?
First, let's check to see that our data table is ready for a pivot table... What are we missing? Well, in order for a pivot table to function properly and include all columns selected, each column must have a column header. In this data set, we're missing the header in column A. Let's add one and then insert our pivot table.
To insert a pivot table: Highlight your data table (A1:D9) > Insert > Pivot Table > New Worksheet > OK
Now, we're ready to include our dates in the Rows. Add the "Date of Purchase" field to the Rows area:
The Resulting table looks like this:
Now, lets group by the date:
- Click on a date in the pivot table
- Right-click the same date you just selected
- Click "Group..."
- For this example, choose both "Months" and "Years" (**to de-select an item just click it again!)
- Click OK
**Tip: If you are getting an error when trying to click "Group...", check to make sure that none of your cells in your date column are blank. Excel will not allow you to group with blank cells.
Now, Add the Price field to the values field in your pivot table. Your pivot table will now look like this:
The above example shows us how to group the data by year and month.
Now, how do we add the individual dates underneath the month? For this, we will need to make some additions to our table. Add the following formulas into the columns next to the table:
Auto-fill or copy/paste the formulas down to the end of the table.
*I'm also going to change the bottom date value to 2/2/2014 for purposes of this example.
Use the following steps to create the desired table:
- Highlight the data table
- Insert Pivot Table on a New Worksheet
- Add (in this order) Year, Month, Date of Purchase to the rows section of the pivot table
- Add Price to the values section of the pivot table
You now have a pivot table that groups the data By Year, By Month AND has individual line items under the month.
Last, since we're looking at dollars, let's format the "Sum of Price" column as currency:
- Double-click on "Sum of Price" column header in the pivot table
- Click the "Number Format" button at the bottom of the Value Field Settings pop-up window
- Choose "Currency" and your preferred format for negative numbers
- Click "OK"
You now have this:
There are lots of great ways to make data more meaningful through the use of pivot tables. In the future I will discuss using Power Pivot, data models, and slicers to be more efficient and effective in your work.
No comments:
Post a Comment