在 Excel 2016 数据模型中创建计算表

Create calculated tables in Excel 2016 Data Model

我在 Excel 2016 数据模型中有多个表。这些表来自其他 excel 工作表中维护的数据,并通过 Excel 查询导入以填充数据模型,以利用可用的高级数据管理功能(例如,DAX、日期表、关系连接)等)

但是,我希望能够通过应用过滤器、联合等来创建 "calculated tables"(使用 DAX 表达式)以定位和转换现有数据元素。目标是在数据模型中使用 "calculated tables" 数据透视表等。这在 Excel 2016 年内可能吗?如果不是,需要哪些辅助工具(SQL 除外)? TIA.

我不这么认为。

Here(虽然我注意到文章是旧的):

Unfortunately, calculated tables are not available in Excel 2016. If you need a similar solution with Excel 2016, you can rely on linked back tables (i.e. queries over the data model materialized in Excel tables and then loaded back in the model). The only limitation is that the size of linked back tables cannot exceed the physical limit of 1M rows of Excel, whereas DAX calculated tables have no limit in size and can work in many more scenarios, resulting in a very elegant and neat model.

我认为它适用于 Power BI,特别是使用 "New Table" 功能和 SSAS 表格使用新计算的 table:

Uses for the New Table Feature in Power BI

This is only available in Power BI Desktop and not in any of the Excel versions or SSAS Tabular. This feature is essentially a “Calculated Table” function. You can pass any valid DAX measure that returns a table of values, and the table will be materialised and loaded into the data model.

并使用 SSAS calculated table

How to create a calculated table

First, verify the tabular model has a compatibility level of 1200 or higher. You can check the Compatibility Level property on the model in SSDT.

Switch to the Data View. You can't create a calculated table in Diagram View.

Select Table > New calculated table.

Type or paste a DAX expression (see below for some ideas).

Name the table.

Create relationships to other tables in the model. See Create a Relationship Between Two Tables (SSAS Tabular) if you need help with this step.

Reference the table in calculations or expressions in your model or use Analyze in Excel for ad hoc data exploration.

截至目前(2019 年 8 月),Excel 支持使用 DAX 生成计算的 table。我个人认为微软应该考虑这一点,因为 DAX 在数据聚合和分析方面非常高效。

获取并转换

在 Microsoft 实施此功能之前,Excel(2010 年以后的版本)有一个很好的替代方法,即利用 Get 和 Transform (在旧版本中也称为 PowerQuery)。

使用此工具,您将能够加载相同的数据集(table 或其他数据源)并将其作为单独的 table 转换到数据模型中。

优点:

  • 它在源数据转换方面功能强大,超越了简单的过滤,可以处理导入原始数据提取。

我个人使用了这种方法,为我节省了大量时间。

缺点:

  • 与 DAX 相比,Get and Transform 是一种较慢且间接的解决方案。
  • 只要源数据发生变化,您就需要刷新查询源。

它位于哪里

  • 在 Excel 2016 年,获取和转换工具可用 Data/New 查询。

如果您需要对我的回答做进一步的解释,请告诉我。

是的,可以将 DAX table 添加到 Excel 中的数据模型。

  • 使用现有连接获取任何 table 到 Excel sheet.

右键单击 table 和 select 编辑 DAX。然后在 EVALUATE 命令后调整你的 DAX 代码。

将来自 Excel sheet 的 table 这个新的 DAX 形状添加到您的数据模型中。