Skip to Content
学习 Microsoft Power BI
book

学习 Microsoft Power BI

by Jeremey Arnold
May 2025
Intermediate to advanced
310 pages
4h 3m
Chinese
O'Reilly Media, Inc.
Content preview from 学习 Microsoft Power BI

附录 A. 常用 DAX 表达式

在本附录中,我将介绍 Power BI 中最常用的一些 DAX 函数的语法。 这些函数按章节编排,然后在章节中按字母顺序排列。对于每个函数,我们都将简要说明该函数的用途、语法,然后给出一个使用该语法的示例。

这并不是 DAX 语言所有函数的详尽列表。请参阅"DAX 函数参考"。

就像许多事情一样,DAX 是帕累托原则的典型例子:掌握 20% 的技能(投入),就能解决 80% 的问题(产出)。

聚合功能

平均值

定义

返回一列所有数值的平均值。

语法

AVERAGE ( [ColumnName] )

示例

AverageScore = AVERAGE ( GradeScore[Score] )

AVERAGEX

定义

计算对表格每一行求值的一组表达式的平均值(均值)。

语法

AVERAGEX ( 'TableName' , <expression> )

示例

AverageScorePercentage = AVERAGEX ( 'GradeScores', 'GradeScores'[Score] + 
  'GradeScores'[MaximumPossibleScore] )

COUNT

定义

返回一列中不空白的记录数。

语法

COUNT ( [ColumnName] )

示例

CountOfStudents = COUNT ( 'UniversitySuppliedData'[StudentID] )

DISTINCTCOUNT

定义

返回给定列中不同值的个数。

语法

DISTINCTCOUNT ( [ColumnName] )

示例

CountOfStudents = DISTINCTCOUNT ( 'GradeScores'[StudentID] )

最大

定义

返回列中的最大值。

语法

MAX ( [ColumnName] )

示例

HighestScore = MAX ( 'GradeScores'[Score] )

MAXX

定义

返回给定表格每一行中表达式的最大值。

语法

MAXX ( 'TableName', <expression> )

示例

LargestScoreAndOfficeHours = MAXX ( 'GradeScores', 'GradeScores'[Score] + 
  'GradeScores'[OfficeHoursAttended] )

MIN

定义

返回一列中的最小值。

语法

MIN ( [ColumnName] )

示例

LowestScore = MIN ( 'GradeScores'[Score] )

MINX

定义

返回给定表格每一行中表达式的最小值。

语法

MINX ( 'TableName', <expression> )

示例

LowestScoreAndOfficeHours = MINX ( 'GradeScores', 'GradeScores'[Score] + 
  'GradeScores'[OfficeHoursAttended] )

总计

定义

将给定列中的所有数字相加。

语法

SUM ( [ColumnName] )

示例

TotalOfficeHoursAttended = SUM ( 'GradeScores'[OfficeHoursAttended] )
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Microsoft Power BI Visual Calculations: Simplifying DAX

Microsoft Power BI Visual Calculations: Simplifying DAX

Jeroen ter Heerdt, Madzy Stikkelorum, Marc Lelijveld

Publisher Resources

ISBN: 9798341658011