Pivot Table Filtering

rasinc

Board Regular
Joined
Jun 28, 2011
Messages
131
I have a pivot table report that uses data pulled from a database through VBA and placed on a sheet that is the source of the pivot table data. I've been using this method for years and it works well.

The current Sales report spans a few years if the user wishes (date range is dynamic for each run). The data has a column for Invoice date and Fiscal year. Fiscal year for a company can be any date range but in this case is Dec-Nov. Showing sales figure columns for fiscal year is easy so the owner of the company can see annual sales for each customer (rows).

When users typically ask for YTD reports they run them from one date over a few years in question and ending usually at the end of the current month. If they wish to show only the fiscal year to the current month for each year then they filter only for the months required based on Invoice Date.

eg. Date range 12/1/2019 to 6/30/2022. This will result in three columns for the years 2020, 2021 and 2022 with 2022 going from Dec/21 to Jun/22 including the full month.

My client has now informed me that if today is Jun 15 then he would like the YTD reporting to end Jun 15. There is no problem here for 2022 because the end date of the pulling of the raw data has a start and end date so he can just enter Jun 15/22 instead of Jun 30/22. However, the complication came up when he said and I want each year to end Jun 15.

I know I can parse the date range and modify the WHERE statement in my VBA SQL statement. What I am trying to figure out is if there is any way for the filtering in a pivot table to be able to do this. Each year from 2020 should be able to display only Dec 1/19 to Jun 15/20, Dec 1/20 to Jun 15/21 and Dec 1/21 to Jun 15/22 as the three columns.

Is there any way to handle this directly in the pivot table using a multi-year date range for the raw data or should I modify my WHERE clause to narrow down the raw data for the report?

TIA, rasinc.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,223,914
Messages
6,175,351
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top