vba 如何将数据添加到现有的功率数据透视表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4031316/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:14:22  来源:igfitidea点击:

How to add data to an existing power pivot table?

excelvbapowerpivot

提问by Patrick DNS

I'm looking for a way to load more recent data as date x in Power Pivot and link/add them to an existing table.

我正在寻找一种方法来在 Power Pivot 中加载更多最新数据作为日期 x 并将它们链接/添加到现有表中。

Background:

背景:

The user downloads data from a datafeed and saves them in Excel Power Pivot.
The data will be deleted from the server afterwards.
In the next step, new data must be added to the existing table in Power Pivot, so that the workbook graphics can access the complete dataset.

用户从数据馈送下载数据并将其保存在 Excel Power Pivot 中。
之后数据将从服务器中删除。
在下一步中,必须将新数据添加到 Power Pivot 中的现有表中,以便工作簿图形可以访问完整的数据集。

I know there is no API for VBA access to Power Pivot. Is there a workaround with linked tables and direct access to the database?

我知道没有用于 VBA 访问 Power Pivot 的 API。是否有链接表和直接访问数据库的解决方法?

回答by Raffael

1) you create one table just containing the dates from earliest to far into the future

1)您创建了一张表格,其中仅包含从最早到未来的日期

2) you import every new set of data into a new power pivot table

2)您将每组新数据导入新的功率数据透视表

3) you link the dates for a record in the newly imported table to the dates in the power pivot table containing the dates

3)您将新导入表中记录的日期链接到包含日期的功率数据透视表中的日期

so the backbone of your whole data is the dates table, while your tables keeping the actual data are treated as lookup tables.

所以整个数据的主干是日期表,而保存实际数据的表被视为查找表。

this is hacky and I didn't try it, but it should work

这是hacky,我没有尝试过,但它应该可以工作