Month & Week grouping in excel pivot tables with some empty data - excel

I am working to group data in excel and I am trying to sort the input dates by month and week. I've found a number of ways to group by weeks (including grouping the date by 7 days and adding a helper column in the pivot table that numbers the weeks), but I'm having a problem viewing months and weeks without data.
For example, in my data set during the month of October, 2 of the weeks have no input. When I try to make the pivot table "show rows with no data" it shows every week in the year, not only the weeks during the month of October.
I would like be able to show every week during the month of October, including those without data, without showing every week in the year. Has anyone encountered a similar issue? I'm on Excel 2016 but my colleague has the same issue on Excel 2013.
Thanks!
Here is a quick screenshot of the pivot table from the data. I am trying to make all of the weeks in the month of October show up regardless of whether or not there is data, but I don't want to see all of the weeks in the date range. I have sample data input from September 16th, 2018 to January 1st, 2019

Update for anyone looking to do this themselves:
I couldn't figure out a way to do this with Pivot Charts. They lack the ability to group by multiple days as well as by months and years. Instead, I used VBA to select the desired data from the pivot table by checking for the number of the month in each row. (mm/dd/yyyy - mm/dd/yyyy is the format pivot tables use to group days).
I added a dummy row which copied the date ("Date 2") and used that, grouped in 7 days, as the rows for the pivot table. Because I wanted to show items with 0 data I selected that option, which shows every group of 7 days from the first day entered until the last day entered. I used the original Date with Month and Year auto groups to insert Slicers to sort the data.
In VBA you can check which Slicers are selected and use that to determine the range of months you want to display on the inserted chart. This way you can look at one or two months at a time but still show weeks with no data.
While this solution is not particularly elegant, it did allow for a dynamic use of the data that can be adjusted to view specific months or years as was desired. Some useful resources for this method are included below. Again, it is an ugly way to get the desired result but if it works it works!
https://peltiertech.com/referencing-pivot-table-ranges-in-vba/
https://peltiertech.com/create-update-chart-using-partial-pivot-table/

Related

How can I make ExCel generate a simple plot of value vs day if the days span more than one year?

ExCel 365
ExCel novice, so please bear with me....
If I have a spreadsheet with 2 columns, a date and a value. I want to plot the value (Y-axis) as it changes per day (X-axis). So I go ahead and select some day/values from my spreadsheet which just happen so span from late November to early December, a total of 6 values (keeping it simple).
Next I insert a pivot table and the "Pivot Table Fields" pane pops up. At the top I see the first date, and the first value. So I drag the date down to the "Rows" sub-pane. A "Months" line pops up at the top of the Pivot Table Pane and it's selected. My 6 data points have been reduced to 2, one for November, one for December. I don't want that so I deselect the "Month" and Viola! I have my 6 dates back. I proceed to finish the plot successfully. That's when the dates span across more than one month.
Now, Same thing only they span over 2 years. Still a puny 6 dates, the last 3 days of December 2016 and the first 3 of January 2017. Just like before I drag the date down to the "Rows" sub-pane only this time I no longer get the "Months" but get instead "Years" and "Quarters". Not terribly surprising, I know what to do, I deselect Years and Quarters but there is no "Months" to delelect. And after deselecting Years and Quarters, my 6 dates have been reduced to 2 months, December and January. There is no "Months" to deselect so I can't re-expand to get my 6 dates. And of course I can't generate the plot of the 6 days vs value because it lost it's sense of the days (apparently)
Is there a way I can get the day resolution back for plotting ?
With your data selected, try inserting the pivot table with these steps:
Select table or range
New or existing worksheet (whichever you prefer)
Then check the box "Add this data to the Data Model". This is the key to what you're looking for, I believe.
Click ok and the data should be laid out horizontally with the dates specified.
As much as I advocate pivot tables, they can sometimes be too smart for their own good. Is there a reason not to use a chart here? With the chart, you can right click the date axis, select "Format axis..." and then under Axis type, select "Text axis". That will prevent Excel from being too helpful and inserting all the dates in between the dates in your data.

Calculating the Difference in Dates in Excel, and Pivot Tables

I'm trying to do the same thing(ish), as in another question, but I'm perplexed by the answer as it doesn't add up for me. It might help if you see this referenced question (Calculate difference from previous date in Excel pivot table). Why is it that in this solution example does the difference in dates show up as 43165 ("days"—I'm assuming)? My model is working to show days between subscription start dates and end dates. So it's should be pretty much the same thing.
Further more, I don't understand why it is when I do a date difference calculation inside the excel table that it works, but when I use it as a calculated field in a pivot table it doesn't work. This is the Formula I used. =ABS(MONTH(J2)-MONTH(D2))+1
I used Absolute because it was showing negatives. I added 1 month to account for the current month and because subs showing less than 30 days, would display 0(zero) months.
Thanks in advance,

Pivot Table: Remove the blank 'year' +/- dropdown row whilst keeping months separated by year

The format of my pivot table (which summarizes 3 years of data) is making down-river calculations very nasty. Is there a way to remove the blank rows created when grouping by month & year?
This is not a one time task, unfortunately - the data could be from any date onwards, but it will always have three years of data (by day) that needs to be averaged by month.
Pivot Table example, bad rows highlighted
NOTE - see my last question, if you can't remove the rows
Fixed - just needed to display the pivot table in tabular form. Pivot Table Design>Report Layout>Tabular –

Pivot table cannot find difference between January current year to December of previous year. Excel 2010

I am weeks into making my first ever pivot tables, cant believe the power of them but have hit a snag I cannot overcome.
I have a worksheet which has a column with raw data (manually imputed)
Then I have another 2 columns that calculate the difference from the previous month and the % difference. This works fine.
As you can see January 2015 is blank as the difference field is looking for the previous month and January is the first month.
how can I get it to understand to look at December 2014
When there are two different levels of grouping, i.e. Year and Month, it is not possible to get Excel to compare the last item of one group with the first item of the previous group.
Excel treats the additional level of grouping as a different field, which is visible when looking at the PivotTable fields. The Years of the Date show as a separate field:
When choosing to calculate the difference, Excel can only compare to values within the same field. Note that you can compare to a specific month value, but not a specific month of a specific year:
Similarly, Excel can't compare to values from the previous grouping, even though human-logic knows it's the previous value in the overall sequence.
To see the difference between each month across years, it's necessary to have all Year-Months in a single field. This isn't possible using PivotTable grouping on normal dates.
The workaround requires a new field to be added to the data which contains a single value per Year-Month. The PivotTable will then naturally group the data by these Year-Month values.
There are two ways this can be achieved:
Calculate the first day of each Year-Month
Insert another column with this formula (referring to a date in the A2 cell):
=Date(Year(A2),Month(A2),1)
This performs the grouping before the data goes into the PivotTable by treating every date as the first of the month. In the PivotTable, the full date will appear by default. You can apply Custom Number Formatting to the field to display only the Month and Year, for example: "mmm yyyy"
This is a better solution when grouping by months as it allows more formatting options.
Calculate a text value for each Year-Month
Insert a column with this formula:
=TEXT(A2,"yyyy mm")
For example, the following data:
Can generate this PivotTable (with sums and then differences):
The text solution has the drawback that you must specify the Year and then Month numerically (and padded to 4 and 2 digits respectively) if you want the PivotTable to automatically order the values in chronological order.
The benefit of the text solution is greater flexibility. For example, you could group bi-monthly with more advanced formulas or group two fields of actual data together by concatenation.
Have you tried combining the month and year in one cell? So on the source data, in the month column have:
Aug-14
Sep-14
Oct-14
Nov-14
Dec-14
Jan-15
Instead of having one column for month name and one for year.
Make sure that once you input the months in your raw data tab, they go to the right side of the cell meaning that Excel sees them as dates not text.

Dealing with overlaping week and year numbers in Excel

A new year with new problems! I have several Excel based rapports that pull data from an Oracle table. However i noticed a problem related to year and weeks in Excel. Here is and example:
The formula i use now is Week(A1;21) for the week and Year(A1) for the year.
Is there a way that i can get the correct year for the whole week based on the date in excel (see week 1 of 2015 in the picture above)
The result i want is this:
This is a possible solution:
=YEAR(A1)+AND(WEEKNUM(A1;21)=1;MONTH(A1)=12)

Resources