Power BI Desktop 中的 DAX 基本概念DAX basics in Power BI Desktop

本文适用于刚开始使用 Power BI Desktop 的用户。This article is for users new to Power BI Desktop. 其目的是为你提供有关如何使用数据分析表达式 (DAX) 的快速而简单的介绍,以便解决一些基本计算和数据分析问题。It’s meant to give you a quick and easy introduction on how you can use Data Analysis Expressions (DAX) to solve a number of basic calculation and data analysis problems. 我们将逐一探讨一些概念性信息、一系列可以完成的任务以及测试所学内容的几项测验。We’ll go over some conceptual information, a series of tasks you can complete, and a few quizzes to test what you’ve learned. 学习完本文后,你便可充分了解 DAX 中最重要的基本概念。After completing this article, you should have a good understanding of the most important fundamental concepts in DAX.

DAX 是什么?What is DAX?

DAX 是公式或表达式中可用于计算并返回一个或多个值的函数、运算符或常量的集合。DAX is a collection of functions, operators, and constants that can be used in a formula, or expression, to calculate and return one or more values. 简单来说,DAX 可帮助你通过模型中已有的数据来创建新信息。Stated more simply, DAX helps you create new information from data already in your model.

为什么 DAX 很重要?Why is DAX so important?

创建新的 Power BI Desktop 文件并导入一些数据非常简单。It’s quite easy to create a new Power BI Desktop file and import some data into it. 你甚至可以创建显示宝贵见解的报表,而完全不需要使用任何 DAX 公式。You can even create reports that show valuable insights without using any DAX formulas at all. 但是,如果你需要分析跨产品类别和不同日期范围内的增长百分比,该怎么办?But, what if you need to analyze growth percentage across product categories and for different date ranges? 或者,需要计算相对于市场趋势的年增长额,该怎么办?Or, you need calculate year-over-year growth compared to market trends? DAX 公式具备这项功能以及许多其他重要功能。DAX formulas provide this capability and many other important capabilities as well. 了解如何创建有效的 DAX 公式可帮助你充分利用数据。Learning how to create effective DAX formulas will help you get the most out of your data. 获取所需信息后,便可开始解决影响最终赢利的实际商业问题。When you get the information you need, you can begin to solve real business problems that affect your bottom line. 这便是 Power BI 的强大之处,而 DAX 将帮助你达成目的。This is the power in Power BI, and DAX will help you get there.


你可能已经熟悉如何在 Microsoft Excel 中创建公式。You might already be familiar with creating formulas in Microsoft Excel. 这一知识有助于了解 DAX,但即使你没有使用 Excel 公式的经验,此处描述的概念也将帮助你开始创建 DAX 公式并立即解决真实世界的 BI 问题。That knowledge will be helpful in understanding DAX, but even if you have no experience with Excel formulas, the concepts described here will help you get started creating DAX formulas and solving real-world BI problems right away.

我们将重点介绍计算中所用的 DAX 公式,更确切地说,也就是度量值和计算列中所用的 DAX 公式。We’re going to focus on understanding DAX formulas used in calculations, more specifically, in measures and calculated columns. 你应该已经熟悉 Power BI Desktop、导入数据、将字段添加到报表,而且还应熟悉度量值计算列的基本概念。You should already be familiar with Power BI Desktop, importing data, adding fields to a report, and you should also be familiar with fundamental concepts of Measures and Calculated columns.

示例工作簿Example Workbook

了解 DAX 的最佳方式是创建一些基本公式,用它来处理一些实际数据,并亲自查看结果。The best way to learn DAX is to create some basic formulas, use it with some actual data, and see the results for yourself. 此处的示例和任务使用 Power BI Desktop Preview 的 Contoso 销售示例文件。The examples and tasks here use the Contoso Sales Sample for Power BI Desktop Preview file. 这是在《教程:在 Power BI Desktop 中创建自己的度量值》一文中所用的相同示例文件。This is the same sample file used in the Tutorial: Create your own measures in Power BI Desktop article. 可以在此处下载该文件。You can download it here.

现在就开始吧!Let's begin!

我们将围绕三个基本概念来了解 DAX:语法、函数和上下文。We will frame our understanding of DAX around three fundamental concepts: Syntax, Functions, and Context. 当然,DAX 还有其他重要概念,但了解这三个概念将为你学习 DAX 技能奠定最佳基础。Of course, there are other important concepts in DAX, but understanding these three concepts will provide the best foundation on which to build your DAX skills.


创建你自己的公式之前,我们来看看 DAX 公式语法。Before you create your own formulas, let’s take a look at DAX formula syntax. 语法包括组成公式的各种元素,简单来说就是公式的编写方式。Syntax includes the various elements that make up a formula, or more simply, how the formula is written. 例如,我们来看一下某个度量值的简单 DAX 公式。For example, let’s look at a simple DAX formula for a measure.

此公式包含以下语法元素:This formula includes the following syntax elements:

A.A. 度量值名称 Total SalesThe measure name Total Sales.

B.B. 等号运算符 (=) 表示公式的开头。The equals sign operator (=) indicates the beginning of the formula. 完成计算后将会返回结果。When calculated, it will return a result.

C.C. DAX 函数 SUM 会将 Sales[SalesAmount] 列中的所有数字相加。The DAX function SUM adds up all of the numbers in the Sales[SalesAmount] column. 稍后你将了解有关函数的详细信息。You’ll learn more about functions later.

D.D. 括号 () 会括住包含一个或多个参数的表达式。Parenthesis () surround an expression containing one or more arguments. 所有函数都至少需要一个参数。All functions require at least one argument. 一个参数会传递一个值给函数。An argument passes a value to a function.

E.E. 引用的表 SalesThe referenced table Sales.

F.F. Sales 表中的引用列 [SalesAmount]The referenced column [SalesAmount] in the Sales table. 使用此参数,SUM 函数就知道在哪一列上进行聚合求和。With this argument, the SUM function knows on which column to aggregate a SUM.

尝试了解 DAX 公式时,将每个元素分解成你平日思考及说出的话语会很有帮助。When trying to understand a DAX formula, it is often helpful to break down each of the elements into a language you think and speak every day. 例如,你可以将此公式读成:For example, you can read this formula as:

对于名为 Total Sales 度量值,计算 (=) Sales 表的 [SalesAmount] 列中的值的总和。For the measure named Total Sales, calculate (=) the SUM of values in the [SalesAmount ] column in the Sales table.

添加到报表后,此度量值会将所包括的其他每个字段的销售额(例如美国的手机)相加,进行计算并返回值。When added to a report, this measure calculates and returns values by summing up sales amounts for each of the other fields we include, for example, Cell Phones in the USA.

你可能会想,“这个度量值的功能不是与直接将 SalesAmount 字段添加到我的报表中一样吗?”You might be thinking ‘Isn’t this measure doing the same thing as if I were to just add the SalesAmount field to my report?’ 没错。Well, yes. 但是,创建自己的度量值来对 SalesAmount 字段中的值求和有个好处:我们可以将它当作参数用于其他公式。But, there’s a good reason to create our own measure that sums up values from the SalesAmount field: We can use it as an argument in other formulas. 虽然现在可能有点难以理解,但随着你对DAX 公式的熟悉,了解这点可让你的公式和模型更有效率。This may seem a little confusing now, but as your DAX formula skills grow, knowing this will make your formulas and your model more efficient. 事实上,稍后你将看到 Total Sales 度量值如何显示为其他公式中的参数。In-fact, you’ll see the Total Sales measure showing up as an argument in other formulas later on.

现在我们将讨论关于此公式的一些其他内容。Let’s go over a few more things about this formula. 我们将着重介绍 SUM 函数。In particular, we introduced a function, SUM. 函数是预编写的公式,能够简化复杂计算和对数字、日期、时间、文本等内容的操作。Functions are pre-written formulas that make it easier to do complex calculations and manipulations with numbers, dates, time, text, and more. 稍后你将了解有关函数的详细信息。You will learn more about functions later.

你还会看到 [SalesAmount] 列前面加上了列所属的 Sales 表。You also see the column [SalesAmount] was preceded by the table Sales in which the column belongs. 这就是所谓的完全限定列名称,因为它包括列名称且前面加上了表名。This is known as a fully qualified column name in that it includes the column name preceded by the table name. 同一表中引用的列不需要在公式中包含该表名。Columns referenced in the same table do not require the table name be included in the formula. 这可让引用许多列的冗长公式更短且更易于阅读。This can make long formulas that reference many columns shorter and easier to read. 但是,最好能够在你的度量值公式中包含表名,即使在同一表中亦然。However, it's good practice to include the table name in your measure formulas, even when in the same table.


如果表名包含空格、保留的关键字或不允许的字符,则需用单引号引住该表名。If a table name contains spaces, reserved keywords, or disallowed characters, you’ll need to enclose the table name in single quotation marks. 如果该名称包含 ANSI 字母数字字符范围以外的任何字符,则不论你的区域设置是否支持字符集,均需用引号引住表名。You’ll also need to enclose table names in quotation marks if the name contains any characters outside the ANSI alphanumeric character range, regardless of whether your locale supports the character set or not.

公式语法的正确性非常重要。It’s important your formulas have the correct syntax. 大多数情况下,如果语法不正确,将返回语法错误。In most cases, if the syntax is not correct, a syntax error will be returned. 其他情况下,语法可能正确,但返回的值可能不是预期值。In other cases, the syntax may be correct, but the values returned might not be what you are expecting. Power BI Desktop 中的 DAX 编辑器包括了建议;这项功能通过帮助你选择正确的元素来创建语法正确的公式。The DAX editor in Power BI Desktop includes suggestions; a feature used to create syntactically correct formulas by helping you select the correct elements.

我们来创建一个简单公式。Let’s create a simple formula. 此任务将帮助你进一步了解公式语法以及编辑栏中的建议功能可以起到怎样的作用。This task will help you further understand formula syntax and how the suggestions feature in the formula bar can help you.

任务:创建度量值公式Task: Create a measure formula

若要完成此任务,需要打开 Power BI Desktop 的 Contoso 销售示例文件。To complete this task, you’ll need to open the Contoso Sales Sample Power BI Desktop file.

  1. 在“报表”视图的字段列表中,右键单击 Sales 表,然后单击新度量值In Report view, in the field list, right-click on the Sales table, and then click New Measure.

  2. 在编辑栏中,通过键入新的度量值名称 Previous Quarter Sales 来替换度量值In the formula bar, replace Measure by typing a new measure name, Previous Quarter Sales.

  3. 在等号后键入 SUM,其后紧跟左括号。After the equals sign, type SUM followed by an opening parenthesis.

    我们将输入另一个函数来筛选想要求和的数据,而不是立即键入列名来求和。Rather than type a column name to sum up right away, we’re going to enter another function, to filter the data we want to sum up.

  4. 在括号中,键入 CALCULATE,其后紧跟左括号。Between the parentheses, type CALCULATE, followed by an opening parenthesis.

    你将通过我们传递给 CALCULATE 函数的参数,使用 CALCULATE 函数来筛选要求和的金额。You’ll use the CALCULATE function to filter the amounts we want to sum by an argument we pass to the CALCULATE function. 这就是所谓的嵌套函数。This is what’s referred to as nesting functions. CALCULATE 函数至少有两个参数。The CALCULATE function has at least two arguments. 第一个参数是要计算的表达式,第二个参数是筛选器。The first is the expression to be evaluated, and second, a filter.

  5. CALCULATE 函数的括号 () 中,键入 Sales[SalesAmount]Between the parenthesis () for the CALCULATE function, type Sales[SalesAmount]. 这是 CALCULATE 函数的第一个表达式参数。This is the first expression argument for our CALCULATE function.

  6. 键入逗号 (“,”) 来指定第一个筛选器,然后键入“PREVIOUSQUARTER”,其后紧跟左括号。Type a comma (,) to specify the first filter, then type PREVIOUSQUARTER followed by an opening parenthesis..

    你将使用 PREVIOUSQUARTER 时间智能函数按上一季度来筛选求和结果。You’ll use the PREVIOUSQUARTER time intelligence function to filter our SUM results by the previous quarter.

  7. 在 PREVIOUSQUARTER 函数的括号 () 中,键入“Calendar[DateKey]”。Between the parenthesis () for the PREVIOUSQUARTER function, type Calendar[DateKey].

    PREVIOUSQUARTER 函数有一个参数,即包含连续日期范围的列。The PREVIOUSQUARTER function has one argument, a column containing a contiguous range of dates. >

  8. 请确保传递给 PREVIOUSQUARTER 和 CALCULATE 函数的两个自变量都后跟两个右括号 ))Make sure both the arguments being passed to the PREVIOUSQUARTER function and the CALCULATE function are closed by two closing parentheses )).

    该公式现在应如下所示:Your formula should now look like this:

    Previous Quarter Sales = CALCULATE(SUM(Sales[SalesAmount]), PREVIOUSQUARTER(Calendar[DateKey]))Previous Quarter Sales = CALCULATE(SUM(Sales[SalesAmount]), PREVIOUSQUARTER(Calendar[DateKey]))

  9. 单击公式栏中的复选标记 或按 Enter 键,验证公式并将其添加到模型中。Click the checkmark in the formula bar or press Enter to validate the formula and add it to the model.

你做到了!You did it! 你刚才使用 DAX 创建的度量值并不简单。You just created a measure using DAX, and not an easy one at that. 这个公式将根据报表中应用的筛选器来计算上一季度的总销售额。What this formula will do is calculate the total sales for the previous quarter, depending on the filters applied in a report. 例如,如果我们将 SalesAmount 和新的 Previous Quarter Sales 度量值放置于图表中,然后添加 Year 和 QuarterOfYear 作为切片器,则会得到类似下面的结果:For example, if we put SalesAmount and our new Previous Quarter Sales measure in a chart, and then added Year and QuarterOfYear as Slicers, we’d get something like this:

以上为你介绍了 DAX 公式的几个重要方面。You were just introduced to several important aspects of DAX formulas. 首先,此公式包括两个函数。First, this formula included two functions. 请注意,PREVIOUSQUARTER 时间智能函数被嵌套为参数传递给 CALCULATE 筛选器函数。Notice PREVIOUSQUARTER, a time intelligence, function is nested as an argument passed to CALCULATE, a filter function. DAX 可以包含多达 64 个嵌套函数。DAX formulas can contain up to 64 nested functions. 一个公式不大可能会包含这么多嵌套函数。It’s unlikely a formula would ever contain so many nested functions. 实际上,创建和调试这样的公式会非常困难,而且也不会太快。In fact, such a formula would be very difficult to create and debug, and it probably wouldn’t be very fast either.

在此公式中,你同样使用了筛选器。In this formula, you also used filters. 筛选器会缩小要进行计算的范围。Filters narrow down what will be calculated. 在本例中,你选择了一个筛选器作为参数,它实际上是另一个函数的结果。In this case, you selected one filter as an argument, which is actually the result of another function. 稍后你将了解有关筛选器的详细信息。You will learn more about filters later.

最后,你使用了 CALCULATE 函数。Finally, you used the CALCULATE function. 这是 DAX 中功能最强大的函数之一。This is one of the most powerful functions in DAX. 当你创作模型并创建更复杂的公式时,可能会多次使用此函数。As you author models and create more complex formulas, you will likely use this function many times. CALCULATE 函数不在本文的讨论范围内,但是随着你对 DAX 了解的深入,请重视这个函数。Discussing the CALCULATE function is outside the scope of this article, but as your knowledge of DAX grows, pay special attention to this one.

语法快速测验Syntax QuickQuiz

  1. 编辑栏上这个按钮的功能是什么?What does this button on the formula bar do?

  2. 一律会用什么括住 DAX 公式中的列名?What always surrounds a column name in a DAX formula?

本文末尾将提供解答。Answers are provided at the end of this article.


函数是通过使用特定值、调用参数,并按特定顺序或结构来执行计算的预定义公式。Functions are predefined formulas that perform calculations by using specific values, called arguments, in a particular order or structure. 参数可以是其他函数、另一个公式、表达式、列引用、数字、文本、逻辑值(如 TRUE 或 FALSE)或者常量。Arguments can be other functions, another formula, expression, column references, numbers, text, logical values such as TRUE or FALSE, or constants.

DAX 包括以下函数类别:日期和时间函数、时间智能函数、信息函数、逻辑函数、数学函数、统计函数、文本函数、父/子函数和其他函数。DAX includes the following categories of functions: Date and Time, Time Intelligence,Information, Logical,Mathematical, Statistical, Text, Parent/Child and Other functions. 如果你熟悉 Excel 公式中的函数,那么 DAX 中的很多函数都会让你觉得相似;但是,DAX 函数在以下方面是独一无二的:If you’re familiar with functions in Excel formulas, many of the functions in DAX will appear similar to you; however, DAX functions are unique in the following ways:

  • DAX 函数始终引用完整列或表。A DAX function always references a complete column or a table. 如果你仅想使用某个表或列中的特定值,则可以向公式添加筛选器。If you want to use only particular values from a table or column, you can add filters to the formula.
  • 如果需要逐行自定义计算,DAX 提供可让你将当前行值或相关值用作一种参数的函数,以便执行因上下文而变的计算。If you need to customize calculations on a row-by-row basis, DAX provides functions that let you use the current row value or a related value as a kind of argument, to perform calculations that vary by context. 稍后你将了解有关上下文的详细信息。You will learn more about context later.
  • DAX 包括许多会返回表而非值的函数。DAX includes many functions that return a table rather than a value. 表不会显示出来,但可以将其用于提供其他函数的输入。The table is not displayed, but is used to provide input to other functions. 例如,你可以检索表,然后计算其中的非重复值,或者计算所筛选的表或列的动态总和。For example, you can retrieve a table and then count the distinct values in it, or calculate dynamic sums across filtered tables or columns.
  • DAX 包括各种时间智能函数。DAX includes a variety of time intelligence functions. 这些函数可让你定义或选择日期范围,并基于此范围执行动态计算。These functions let you define or select date ranges, and perform dynamic calculations based on them. 例如,你可以比较并行时间段内的总和。For example, you can compare sums across parallel periods.
  • Excel 有一个非常热门的函数 VLOOKUP。Excel has a very popular function, VLOOKUP. 不同于 Excel 中的 VLOOKUP,DAX 函数不会采用单元格或单元格区域作为引用。DAX functions don’t take a cell or cell range as a reference like VLOOKUP does in Excel. DAX 函数采用某一列或表作为引用。DAX functions take a column or a table as a reference. 请记住,在 Power BI Desktop 中,你会使用关系数据模型。Keep in-mind, in Power BI Desktop, you’re working with a relational data model. 查找另一个表中的值其实非常简单,而且在大多数情况下,完全不需要创建任何公式。Looking up values in another table is really quite easy, and in most cases you don’t need to create any formula at all.

    如你所见,DAX 中的函数可帮助你创建功能非常强大的公式。As you can see, functions in DAX can help you create very powerful formulas. 我们实际上只接触到了函数的基本概念。We really only touched on the basics of functions. 随着你对 DAX 技能的熟悉,你将使用许多不同的函数来创建公式。As your DAX skills grow, you'll create formulas using many different functions. 若要了解有关每个 DAX 函数的详细信息,最好的办法之一就是参阅DAX 函数参考One of the best places to learn details about each of DAX functions is in the DAX Function Reference.

函数快速测验Functions QuickQuiz

  1. 函数会始终引用何项?What does a function always reference?
  2. 一个公式是否可以包含多个函数?Can a formula contain more than one function?
  3. 可以使用哪种函数类别来将两个文本字符串连接成一个字符串?What category of functions would you use to concatenate two text strings into one string?

本文末尾将提供解答。Answers are provided at the end of this article.


上下文是需要了解的重要 DAX 概念之一。Context is one of the most important DAX concepts to understand. DAX 中有两种上下文类型;行上下文和筛选上下文。There are two types of context in DAX; row context and filter context. 首先我们来看看行上下文。We’ll first look at row context.

行上下文Row context

将行上下文想象成当前行是最简单的做法。Row context is most easily thought of as the current row. 每当公式中含有应用了筛选器以识别表中某一行的函数时,都可应用此方法。It applies whenever a formula has a function that applies filters to identify a single row in a table. 函数会应用所筛选的表中每行的固有行上下文。The function will inherently apply a row context for each row of the table over which it is filtering. 这种类型的行上下文最常应用于度量值中。This type of row context most often applies to measures.

筛选器上下文Filter context

筛选上下文比行上下文稍微更难理解。Filter context is a little more difficult to understand than row context. 最简单的做法就是将筛选上下文想象成:决定结果或值的计算中所应用的一个或多个筛选器。You can most easily think of filter context as: One or more filters applied in a calculation that determines a result or value.

筛选上下文并非原本就存在于行上下文中;而是另外应用到行上下文。Filter context doesn’t exist in-place of row context; rather, it applies in addition to row context. 例如,若要进一步缩小要包括在计算中的值,可以应用筛选上下文,该筛选上下文不仅要指定行上下文,还要仅指定该行上下文中的特定值(筛选)。For example, to further narrow down the values to include in a calculation, you can apply a filter context which not only specifies the row context, but also specifies only a particular value (filter) in that row context.

可以在报表中轻松看到筛选上下文。Filter context is easily seen in your reports. 例如,当你将 TotalCost 添加到可视化效果,然后添加 Year 和 Region 时,你正在定义基于给定年份和区域来选择数据子集的筛选上下文。For example, when you add TotalCost to a visualization, and then add Year and Region, you are defining a filter context that selects a subset of data based on a given year and region.

为什么筛选上下文对 DAX 很重要?Why is filter context so important to DAX? 因为不仅可以通过将字段添加到可视化效果而轻松应用筛选上下文,还可以通过使用 ALL、RELATED、FILTER、CALCULATE 等函数,按照关系、其他度量值和列来定义筛选器,从而实现在 DAX 公式中应用筛选上下文。Because while filter context can most easily be applied by adding fields to a visualization, filter context can also be applied in a DAX formula by defining a filter using functions such as ALL, RELATED, FILTER, CALCULATE, by relationships, and by other measures and columns. 例如,我们来看看名为 Store Sales 的度量值中的以下公式:For example, let’s look at the following formula in a measure named Store Sales:

为了更好地理解此公式,我们可以像处理其他公式一样对其进行分解:To better understand this formula, we can break it down, much like with other formulas.

此公式包含以下语法元素:This formula includes the following syntax elements:

A.A. 度量值名称 Store SalesThe measure name Store Sales.

B.B. 等号运算符 (=) 表示公式的开头。The equals sign operator (=) indicates the beginning of the formula.

C.C. CALCULATE 函数会在根据指定筛选器所修改的上下文中,作为参数来计算表达式。The CALCULATE function evaluates an expression, as an argument, in a context that is modified by the specified filters.

D.D. 括号 () 会括住包含一个或多个参数的表达式。Parenthesis () surround an expression containing one or more arguments.

E.E. 同一表中作为表达式的 [Total Sales] 度量值。A measure [Total Sales] in the same table as an expression. Total Sales 度量值的公式为:=SUM(Sales[SalesAmount])。The Total Sales measure has the formula: =SUM(Sales[SalesAmount]).

F.F. 逗号 (,) 会分隔第一个表达式参数和筛选参数。A comma (,) separates the first expression argument from the filter argument.

G.G. 完全限定的引用列为 Channel[ChannelName]The fully qualified referenced column, Channel[ChannelName]. 这是我们的行上下文。This is our row context. 此列中的每行各指定一个通道:Store、Online 等。Each row in this column specifies a channel: Store, Online, etc.

H.H. 将特定值 Store 作为筛选器。The particular value, Store as a filter. 这是我们的筛选上下文。This is our filter context.

此公式可确保仅针对以“Store”值为筛选器的 Channel[ChannelName] 列中的行,计算 Total Sales 度量值所定义的销售额值。This formula ensures only sales values defined by the Total Sales measure are calculated only for rows in the Channel[ChannelName] column with the value “Store”, as a filter.

正如你所想象的,能够在公式内定义筛选上下文是多么巨大且强大的功能。As you can imagine, being able to define filter context within a formula has immense and powerful capabilities. 能够仅引用相关表中的特定值不过是其中一例。Being able to reference only a particular value in a related table is just one such example. 如果你现在尚未完全理解上下文,请不要担心。Don’t worry if you do not completely understand context right away. 创建自己的公式时,你将可以更好地理解上下文以及其在 DAX 中非常重要的原因。As you create your own formulas, you will better understand context and why it’s so important in DAX.

上下文快速测验Context QuickQuiz

  1. 上下文有哪两种类型?What are the two types of context?
  2. 什么是筛选上下文?What is filter context?
  3. 什么是行上下文?What is row context?

本文末尾将提供解答。Answers are provided at the end of this article.


现在你对 DAX 中最重要的概念有了基本的认识,可以开始独立创建度量值的 DAX 公式。Now that you have a basic understanding of the most important concepts in DAX, you can begin creating DAX formulas for measures on your own. DAX 确实有点难以理解,但是有许多资源可供你使用。DAX can indeed be a little tricky to learn, but there are many resources available to you. 读完本文并对自己的几个公式进行试验之后,你可以进一步了解可帮助你解决业务问题的 DAX 概念和公式。After reading through this article and experimenting with a few of your own formulas, you can learn more about other DAX concepts and formulas that can help you solve your own business problems. 有许多 DAX 资源可供你使用;最重要的就是数据分析表达式 (DAX) 参考There are many DAX resources available to you; most important is the Data Analysis Expressions (DAX) Reference.

DAX 在 Power Pivot 和 Analysis Services 表格模型等其他 Microsoft BI 工具中已存在数年,因此有许多有用信息。DAX has been around for several years in other Microsoft BI tools such as Power Pivot and Analysis Services Tabular models, so there’s a lot of great information out there. 你可以从 Microsoft 和顶级 BI 专业人员所提供的书籍、白皮书和博客中找到详细信息。You can find more information in books, whitepapers, and blogs from both Microsoft and leading BI professionals. TechNet 上的 DAX 资源中心 Wiki 也是一个不错的起点。The DAX Resource Center Wiki on TechNet is also a great place to start.

快速测验答案QuickQuiz answers


  1. 验证度量值并将其输入模型中。Validates and enters the measure into the model.
  2. 方括号 []。Brackets [].


  1. 表和列。A table and a column.
  2. 是的。Yes. 公式可以包含多达 64 个嵌套函数。A formula can contain up to 64 nested functions.
  3. 文本函数Text functions.


  1. 行上下文和筛选上下文。Row context and filter context.
  2. 计算中用于确定单个值的一个或多个筛选器。One or more filters in a calculation that determines a single value.
  3. 当前行。The current row.