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 Sales 範例檔案。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

若要完成這項工作,您需要開啟 Contoso Sales 範例 Power BI Desktop 檔案。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.