PowerApps 的公式参考Formula reference for PowerApps

公式组合了许多元素。Formulas combine many elements. 下面列出的包括:Listed below are:

  • 函数,它接受参数、执行操作并返回值。Functions take parameters, perform an operation, and return a value. 例如,Sqrt(25) 返回 5For example, Sqrt(25) returns 5. 函数模仿了 Microsoft Excel 函数。Functions are modeled after Microsoft Excel functions. 某些函数具有副作用,例如 SubmitForm,该函数仅在诸如 Button.OnSelect行为公式中适用。Some functions have side effects, such as SubmitForm, which are appropriate only in a behavior formula such as Button.OnSelect.
  • 信号,它返回关于环境的信息。Signals return information about the environment. 例如,Location 返回设备的当前 GPS 坐标。For example, Location returns the device's current GPS coordinates. 信号不接受参数,也没有副作用。Signals don't take parameters or have side effects.
  • 枚举,它返回预定义的常量值。Enumerations return a pre-defined constant value. 例如,Color 是一个具有预定义值 Color.RedColor.Blue 等等的枚举。For example, Color is an enumeration that has pre-defined values for Color.Red, Color.Blue, and so forth. 此处包括了通用枚举;函数特定的枚举随函数进行了介绍。Common enumerations are included here; function-specific enumerations are described with the function.
  • 已命名运算符,例如 ThisItemParent,用于从容器内访问信息。Named operators, such as ThisItem and Parent, provide access to information from within a container.

其他元素包括:Other elements include:

AA

Abs – 数字的绝对值。Abs – Absolute value of a number.

Acceleration – 读取你的设备中的加速度传感器。Acceleration – Reads the acceleration sensor in your device.

Acos – 以弧度为单位返回某个数字的反余弦值。Acos – Returns the arccosine of a number, in radians.

Acot – 以弧度为单位返回某个数字的反余切值。Acot – Returns the arccotangent of a number, in radians.

AddColumns – 返回添加了的表。 AddColumns – Returns a table with columns added.

And – 布尔逻辑与。And – Boolean logic AND. 如果所有参数都为 true,则返回 trueReturns true if all arguments are true. 还可以使用 && 运算符You can also use the && operator.

App – 返回有关当前正在运行的应用的信息,例如当前显示了哪个屏幕。App – Returns information about the currently running app, such as which screen is currently displayed.

Asin – 以弧度为单位返回某个数字的反正弦值。Asin – Returns the arcsine of a number, in radians.

Atan – 以弧度为单位返回某个数字的反正切值。Atan – Returns the arctangent of a number, in radians.

Atan2 – 基于 (x,y) 坐标以弧度为单位返回反正切。Atan2 – Returns the arctangent based on an (x,y) coordinate, in radians.

Average – 计算某个表表达式或一组参数的平均值。Average – Calculates the average of a table expression or a set of arguments.

BB

Back – 显示上一屏幕。Back – Displays the previous screen.

Blank - 返回可用于在数据源中插入 NULL 值的 空白 值。Blank – Returns a blank value that can be used to insert a NULL value in a data source.

CC

Calendar – 检索有关当前区域设置的日历信息。Calendar – Retrieves information about the calendar for the current locale.

Char – 将字符代码转换为字符串。Char – Translates a character code into a string.

Clear – 删除某个集合中的所有数据。Clear – Deletes all data from a collection.

ClearCollect – 删除某个集合中的所有数据,然后添加一组记录ClearCollect – Deletes all data from a collection and then adds a set of records.

Clock – 检索有关当前区域设置的时钟信息。Clock – Retrieves information about the clock for the current locale.

Coalesce – 替换空值并保留非空值不变。Coalesce – Replaces blank values while leaving non-blank values unchanged.

Collect – 创建一个集合或者向数据源添加数据。Collect – Creates a collection or adds data to a data source.

Color – 将某个属性设置为内置的颜色值。Color – Sets a property to a built-in color value.

ColorFade – 使颜色值变淡。ColorFade – Fades a color value.

ColorValue – 将 CSS 颜色名称或十六进制代码转换为颜色值。ColorValue – Translates a CSS color name or a hex code to a color value.

Compass – 返回你的罗盘航向。Compass – Returns your compass heading.

Concat – 连接数据源中的字符串。Concat – Concatenates strings in a data source.

Concatenate – 连接字符串。Concatenate – Concatenates strings.

Connection – 返回关于你的网络连接的信息。Connection – Returns information about your network connection.

Count – 对包含数字的表记录进行计数。Count – Counts table records that contain numbers.

Cos – 返回以弧度为单位指定的角度的余弦值。Cos – Returns the cosine of an angle specified in radians.

Cot – 返回以弧度为单位指定的角度的余切值。Cot – Returns the cotangent of an angle specified in radians.

CountA – 对不为的表记录进行计数。CountA – Counts table records that aren't empty.

CountIf – 对满足某个条件的表记录进行计数。CountIf – Counts table records that satisfy a condition.

CountRows – 对表记录进行计数。CountRows – Counts table records.

DD

DataSourceInfo – 提供数据源的相关信息。DataSourceInfo – Provides information about a data source.

Date – 基于的值返回日期/时间值。Date – Returns a date/time value, based on Year, Month, and Day values.

DateAdd – 将天数、月数、季度数或年数加到某个日期/时间值上。DateAdd – Adds days, months, quarters, or years to a date/time value.

DateDiff – 将两个日期值相减,并显示以天数、月数、季度数或年数表示的结果。DateDiff – Subtracts two date values, and shows the result in days, months, quarters, or years.

DateTimeValue – 将日期和时间字符串转换为日期/时间值。DateTimeValue – Converts a date and time string to a date/time value.

DateValue – 将纯日期字符串转换为日期/时间值。DateValue – Converts a date-only string to a date/time value.

Day – 检索日期/时间值的日部分。Day – Retrieves the day portion of a date/time value.

Defaults – 返回数据源的默认值。Defaults – Returns the default values for a data source.

Degrees - 将弧度转换为度。Degrees - Converts radians to degrees.

Disable – 禁用某个信号,例如用于读取 GPS 的 LocationDisable – Disables a signal, such as Location for reading the GPS.

Distinct – 对表的记录数进行汇总并删除重复项。Distinct – Summarizes records of a table, removing duplicates.

Download – 将文件从 web 下载到本地设备。Download – Downloads a file from the web to the local device.

DropColumns – 返回删除了一个或多个列后的表。DropColumns – Returns a table with one or more columns removed.

EE

EditForm – 重置用于编辑某个项的表单控件。EditForm – Resets a form control for editing of an item.

Enable – 启用某个信号,例如用于读取 GPS 的 LocationEnable – Enables a signal, such as Location for reading the GPS.

EndsWith – 检查某个文本字符串是否以另一个文本字符串结尾。EndsWith – Checks whether a text string ends with another text string.

Errors – 提供之前对数据源的更改的错误信息。Errors – Provides error information for previous changes to a data source.

EncodeUrl – 使用 URL 编码对特殊字符进行编码。EncodeUrl – Encodes special characters using URL encoding.

Exit – 退出当前正在运行的应用。Exit – Exits the currently running app.

Exp - 返回 e 的乘幂。Exp - Returns e raised to a power.

FF

Filter – 返回基于一个或多个条件筛选后的表。Filter – Returns a filtered table based on one or more criteria.

Find – 检查一个字符串是否出现在另一个字符串内并返回位置。Find – Checks whether one string appears within another and returns the location.

First – 返回表中的第一条记录。First – Returns the first record of a table.

FirstN – 返回表中的第一组记录(N 条记录)。FirstN – Returns the first set of records (N records) of a table.

ForAll – 针对表中的所有记录计算值和执行操作。ForAll – Calculates values and performs actions for all records of a table.

GG

GroupBy – 返回将记录分组在一起的表。GroupBy – Returns a table with records grouped together.

HH

HashTags – 从字符串中提取井号标签 (#strings)。HashTags – Extracts the hashtags (#strings) from a string.

Hour – 返回日期/时间值的小时部分。Hour – Returns the hour portion of a date/time value.

II

If – 如果条件为 true,返回一个值,否则返回另一个值。If – Returns one value if a condition is true and another value if not.

IsBlank – 检查是否为值。IsBlank – Checks for a blank value.

IsEmpty – 检查是否为空表。IsEmpty – Checks for an empty table.

IsMatch – 对照某个模式检查字符串。IsMatch – Checks a string against a pattern. 可以使用正则表达式。Regular expressions can be used.

IsNumeric – 检查是否为数字值。IsNumeric – Checks for a numeric value.

IsToday – 检查某个日期/时间值是否为今天的某个时间。IsToday – Checks whether a date/time value is sometime today.

LL

Language – 返回当前用户的语言标记。Language – Returns the language tag of the current user.

Last – 返回表中的最后一条记录。Last – Returns the last record of a table.

LastN – 返回表中的最后一组记录(N 条记录)。LastN – Returns the last set of records (N records) of a table.

Launch – 启动某个 web 地址或应用。Launch – Launches a web address or an app.

Left – 返回字符串最左侧的部分。Left – Returns the left-most portion of a string.

Len – 返回字符串的长度。Len – Returns the length of a string.

Ln – 返回自然对数。Ln – Returns the natural log.

LoadData – 从 PowerApps 专用存储中加载集合。LoadData – Loads a collection from PowerApps private storage.

Location – 通过使用全球定位系统 (GPS) 和其他信息将你的位置返回为地图坐标。Location – Returns your location as a map coordinate by using the Global Positioning System (GPS) and other information.

LookUp – 基于一个或多个条件在表中查找单条记录。LookUp – Looks up a single record in a table based on one or more criteria.

Lower – 将文本字符串中的字母转换为全部小写。Lower – Converts letters in a string of text to all lowercase.

MM

Max – 某个表表达式或一组参数的最大值。Max – Maximum value of a table expression or a set of arguments.

Mid – 返回字符串的中间部分。Mid – Returns the middle portion of a string.

Min – 某个表表达式或一组参数的最小值。Min – Minimum value of a table expression or a set of arguments.

Minute – 检索日期/时间值的分钟部分。Minute – Retrieves the minute portion of a date/time value.

Mod – 返回被除数除以除数之后的余数。Mod – Returns the remainder after a dividend is divided by a divisor.

Month – 检索日期/时间值的月份部分。Month – Retrieves the month portion of a date/time value.

NN

Navigate – 更改要显示的屏幕。Navigate – Changes which screen is displayed.

NewForm – 重置用于创建某个项的表单控件。NewForm – Resets a form control for creation of an item.

Not – 布尔逻辑非。Not – Boolean logic NOT. 如果其参数为 false,则返回 true;如果其参数为 true,则返回 falseReturns true if its argument is false, and returns false if its argument is true. 还可以使用 ! 运算符You can also use the ! operator.

Now – 返回当前的日期/时间值。Now – Returns the current date/time value.

OO

Or – 布尔逻辑或。Or – Boolean logic OR. 如果其任一参数为 true,则返回 trueReturns true if any of its arguments are true. 还可以使用 || 运算符You can also use the || operator.

PP

Param – 用于访问当用户打开应用时传递给它的参数。Param – Provides access to parameters passed to the app when the user opened it.

Parent – 用于访问容器控件的属性。Parent – Provides access to a container control's properties.

Patch – 在数据源中修改或创建记录,或者在数据源外部合并记录。Patch – Modifies or creates a record in a data source, or merges records outside of a data source.

Pi – 返回数字 π。Pi – Returns the number π.

PlainText – 从字符串中删除 HTML 和 XML 标记。PlainText – Removes HTML and XML tags from a string.

Power – 返回某个数字的乘幂。Power – Returns a number raised to a power. 还可以使用 ^ 运算符You can also use the ^ operator.

Proper – 将字符串中每个单词的首字母转换为大写,将其余字母转换为小写。Proper – Converts the first letter of each word in a string to uppercase, and converts the rest to lowercase.

RR

Radians - 将度转换为弧度。Radians - Converts degrees to radians.

Rand – 返回一个伪随机数。Rand – Returns a pseudo-random number.

Refresh – 刷新数据源的记录。Refresh – Refreshes the records of a data source.

Remove – 从数据源中删除一条或多条特定记录。Remove – Removes one or more specific records from a data source.

RemoveIf – 基于某个条件从数据源中删除记录。RemoveIf – Removes records from a data source based on a condition.

RenameColumns – 重命名表的列。RenameColumns – Renames columns of a table.

Replace – 从字符串的起始位置开始,将一个字符串的一部分替换为另一个字符串。Replace – Replaces part of a string with another string, by starting position of the string.

Reset - 将输入控件重置为默认值,放弃任何用户更改。Reset – Resets an input control to its default value, discarding any user changes.

ResetForm – 重置用于编辑某个现有项的表单控件。ResetForm – Resets a form control for editing of an existing item.

Revert – 重新加载数据源的记录并清除错误。Revert – Reloads and clears errors for the records of a data source.

RGBA – 返回一组红、绿、蓝和 alpha 组件的颜色值。RGBA – Returns a color value for a set of red, green, blue, and alpha components.

Right – 返回字符串最右侧的部分。Right – Returns the right-most portion of a string.

Round – 舍入到最接近的数字。Round – Rounds to the closest number.

RoundDown – 向下舍入到最大的上一数字。RoundDown – Rounds down to the largest previous number.

RoundUp – 向上舍入到最小的下一数字。RoundUp – Rounds up to the smallest next number.

SS

SaveData – 将集合保存到 PowerApps 专用存储。SaveData – Saves a collection to PowerApps private storage.

Search – 在表中查找其某个列中包含某个字符串的记录。Search – Finds records in a table that contain a string in one of their columns.

Second – 检索日期/时间值的秒部分。Second – Retrieves the second portion of a date/time value.

Set – 设置全局变量的值。Set – Sets the value of a global variable.

ShowColumns – 返回仅包含所选列的表。ShowColumns – Returns a table with only selected columns.

Shuffle – 随机重新排列表记录的顺序。Shuffle – Randomly reorders the records of a table.

Sin – 返回以弧度为单位指定的角度的正弦值。Sin – Returns the sine of an angle specified in radians.

Sort – 返回基于某个公式排序后的表。Sort – Returns a sorted table based on a formula.

SortByColumns – 返回基于一个或多个列排序后的表。SortByColumns – Returns a sorted table based on one or more columns.

Split – 将文本字符串拆分成子字符串表。Split – Splits a text string into a table of substrings.

Sqrt – 返回数字的平方根。Sqrt – Returns the square root of a number.

StartsWith – 检查某个文本字符串是否以另一个文本字符串开头。StartsWith – Checks if a text string begins with another text string.

StdevP – 返回其参数的标准偏差。StdevP – Returns the standard deviation of its arguments.

Substitute – 通过对字符串进行匹配,将一个字符串的一部分替换为另一个字符串。Substitute – Replaces part of a string with another string, by matching strings.

SubmitForm – 将表单控件中的项保存到数据源。SubmitForm – Saves the item in a form control to the data source.

Sum – 计算某个表表达式或一组参数的和。Sum – Calculates the sum of a table expression or a set of arguments.

Switch - 先与一组值匹配,再对相应公式求值。Switch – Matches with a set of values and then evaluates a corresponding formula.

TT

Table – 创建一个临时表。Table – Creates a temporary table.

Tan - 返回以弧度为单位指定的角度的正切值。Tan - Returns the tangent of an angle specified in radians.

Text – 将数字设置为字符串格式进行显示。Text – Formats a number as a string for display.

ThisItem – 当在库或表单中时,返回容器中当前项的数据。ThisItem – When in a gallery or form, returns the data for the current item from the container.

Time – 基于小时分钟的值返回日期/时间值。Time – Returns a date/time value, based on Hour, Minute, and Second values.

TimeValue – 将纯时间字符串转换为日期/时间值。TimeValue – Converts a time-only string to a date/time value.

TimeZoneOffset - 返回 UTC 和用户本地时间的时间差(以分钟为单位)。TimeZoneOffset – Returns the difference between UTC and the user's local time in minutes.

Today – 返回当前的日期/时间值。Today – Returns the current date/time value.

Trim – 从文本字符串的末尾和内部删除多余的空格。Trim – Removes extra spaces from the ends and interior of a string of text.

TrimEnds – 仅从文本字符串的末尾删除多余的空格。TrimEnds – Removes extra spaces from the ends of a string of text only.

UU

Ungroup – 删除某个分组。Ungroup – Removes a grouping.

Update – 替换数据源中的某条记录。Update – Replaces a record in a data source.

UpdateContext – 设置当前屏幕的一个或多个上下文变量的值。UpdateContext – Sets the value of one or more context variables of the current screen.

UpdateIf – 基于某个条件修改数据源中的一组记录。UpdateIf – Modifies a set of records in a data source based on a condition.

Upper – 将文本字符串中的字母转换为全部大写。Upper – Converts letters in a string of text to all uppercase.

User – 返回当前用户的相关信息。User – Returns information about the current user.

VV

Validate – 检查单个列或整条记录的值对数据源是否有效。Validate – Checks whether the value of a single column or a complete record is valid for a data source.

Value – 将字符串转换为数字。Value – Converts a string to a number.

VarP – 返回其参数的方差。VarP – Returns the variance of its arguments.

ResetForm – 重置用于查看现有项的表单控件。ViewForm – Resets a form control for viewing of an existing item.

WW

Weekday – 检索日期/时间值的星期几部分。Weekday – Retrieves the weekday portion of a date/time value.

YY

Year – 检索日期/时间值的年份部分。Year – Retrieves the year portion of a date/time value.