Excel 不使用 PowerPivot 的数据模型

Excel Data Model without using PowerPivot

我对 excel 中的 "Data Model" 有疑问。每当我读到此功能时,它都会与 PowerPivot 一起使用。

我问是因为我想做这样的事情:

我有 table A:

table B:

现在,如果我将这些 table 与数据模型函数连接起来(通过 ID 列),我想我可以将 tableB.info2 连接到 tableA 并有一个 table 显示 ID,info1,info2

但这似乎不可能,或者有可能但我做错了什么?

在不使用 PowerPivot 的情况下,您可以使用数据模型做些什么吗?我觉得我错过了这个功能的重点。

PowerPivot 是一种非常先进的工具,可以消除 table 的麻烦。它可以为您节省很多时间。

"Data Model"在PowerPivot、Pivo​​tTables、PowerView的"core",不能脱离这三个工具使用。

你说的是可以实现的,但最好在VLOOKUPINDEX(MATCH())

中处理

但我们只想说我们想沿着那条路走下去,因为老实说,我有时会这样做。

首先,

在 table 1 和 table 2 之间的数据模型中连接您的 ID 值,箭头流向 table 1,只有 info1。

在table1中创建一个计算列,给它公式

=RELATED(table2[info2])

命名您刚添加的新列"related info2"

你的价值神奇地增加了。

但是如何将它放回到 excel 工作簿中呢?它根本不是 "clean" 解决方案,这就是我们推荐 VLOOKUPMATCH(INDEX())

的原因

要将 info2 带入 excel sheet,您需要做的是使用 "Flattened PivotTable"。

您可以在 PowerPivot 编辑器中创建这种类型的数据透视表,方法是按 "PivotTable" 按钮。

将您的 Flattened PivotTable 放在您想要 info2 的 Excel 工作 sheet 的另一个 table 旁边,就像您将神奇地填充旁边的 info2 列一样它,因为你即将。

将包含计算列的 table 中的所有数据透视表字段拖放到 "rows" 框中,包括我们刚刚在 table1 中创建的 "related info2" 列.

要在正确的行上获得正确的值,请进入“设计”选项卡,然后单击 "Subtotals" 按钮,禁用所有小计,然后对 "Grand Totals" 按钮执行相同操作,禁用所有总计。

确保您的 "Report Layout" 是 "Compact",也可以在“设计”选项卡中找到。

Optional: You can add a field to "values" to allow row formatting to recognize the rows, otherwise the PivotTable thinks that there are no rows and you won't get anything but a mostly solid color, no matter how many designs you try to switch to (we're doing something tricky, remember?)

现在隐藏您刚刚使用数据透视表创建的 excel sheet 中的所有列,"related info2" 列除外。

所以是的,这是可能的,但你最好使用 VLOOKUPINDEX(MATCH())

自 Excel 2013 年起,DataModel 可以在没有 PowerPivot 的情况下使用。您可以将表(或其他数据源)加载到其中,甚至可以使用 DAX 添加度量(尽管您不能添加计算列)。查看以下链接以获取示例: https://youtu.be/FVVK-8QZC1M(Mike Girvin 向您展示了如何在没有 PowerPivot 的情况下使用 DAX 来基于数据模型为数据透视表创建度量)

https://blog.crossjoin.co.uk/2012/07/16/what-are-the-big-changes-in-excel-2013-for-bi/(阅读评论以了解 DataModel 如何与 PowerPivot 完全分离。实际上,PowerPivot 只是一个 UI,可让您对 DataModel 执行操作)

https://powerpivotpro.com/2014/07/adding-tables-to-a-model-from-vba-in-excel-2013/(Dany 解释了如何使用 VBA 对数据模型执行操作)

http://dailydoseofexcel.com/archives/2017/07/10/look-ma-no-powerpivot/(我的post,涵盖以上内容)