简体   繁体   English

数据刷新后保留数据透视表报表过滤器

[英]Keep PivotTable report filter after data refresh

I have a PivotTable (actually it is five PivotTables, each on its own separate sheet) that is created from a query of an outside database. 我有一个数据透视表(实际上是五个数据透视表,每个数据透视表都在其自己的单独工作表上)是根据外部数据库的查询创建的。 Each of the PivotTables represents a day (ie Today, Tomorrow, Today+2, Today+3, and Today+4). 每个数据透视表代表一天(即今天,明天,今天+2,今天+3和今天+4)。 For the report filter for the first two, we use a date range filter of today and tomorrow which automatically filters the data and allows it to roll over. 对于前两个报表过滤器,我们使用今天和明天的日期范围过滤器,该日期范围过滤器会自动过滤数据并允许其滚动。 We created custom date ranges for the other three days, but upon every external data refresh we have to go into each sheet and reselect the report filter from all to the specified time frame. 我们为其他三天创建了自定义日期范围,但是在每次刷新外部数据时,我们都必须进入每个工作表,然后从所有表中重新选择报表过滤器,直到指定的时间范围。 This data rolls over every day so we can see the lineup for the next 96 hours out. 该数据每天都会滚动,因此我们可以查看接下来96小时的比赛阵容。

Is there a way to either keep the PivotTable report filter criteria (VBA and macros are both acceptable, although we are also fairly new to both)? 有没有一种方法可以保留数据透视表报表过滤条件(VBA和宏都可以接受,尽管我们对两者都还很陌生)?

Or is there some super secret way to extend the report filter from just today and tomorrow to a time range (48 hours, 96 hours) instead of next month? 还是有某种超级秘密的方法可以将报表过滤器从今天和明天扩展到一个时间范围(48小时,96小时),而不是下个月?

I need the days to be separated, so next week will not work because all the days will populate on one page. 我需要分开几天,所以下周将无法使用,因为所有日子都将填充在一页上。

Without seeing a real example it's hard to tell, but how about changing the query to a relative date index, ie something like 没有看到一个真实的例子,很难说,但是如何将查询更改为相对日期索引,例如

SELECT DATEDIFF('day', GETDATE(), report_dt) AS days_from_today FROM reporting_table

And then set your report filters on this relative date index ( days_from_today = 1 for tomorrow, etc)? 然后在此相对日期索引上设置报表过滤器(对于明天等, days_from_today = 1 ,等等)? You can always create another Excel column in the report =TODAY() + days_from_today to get your absolute date back. 您始终可以在报表=TODAY() + days_from_today创建另一个Excel列,以获取绝对日期。 (Assuming you are just dealing with one time zone for reporting purposes.) (假设您只是为了报告目的而处理一个时区。)

Ie, instead of rolling filters, keep the filters on constant indices, and let the indices cover a rolling date range. 即,代替滚动过滤器,将过滤器保持在恒定索引上,并让索引覆盖滚动日期范围。 I'm not sure Excel is smart enough to do the rolling filters thing. 我不确定Excel是否足够聪明来执行滚动筛选器操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM