PowerApps 中的 Concat 和 Concatenate 函数Concat and Concatenate functions in PowerApps

中的文本和字符串连成单个字符串。Concatenates individual strings of text and strings in tables.

说明Description

Concat 函数可将应用于表中所有记录的公式的结果串联起来,从而产生单个字符串。The Concat function concatenates the result of a formula applied across all the records of a table, resulting in a single string. 使用这个函数可汇总表的字符串,就像 Sum 函数可以汇总数字一样。Use this function to summarize the strings of a table, just as the Sum function does for numbers.

Fields of the record currently being processed are available within the formula. You simply reference them by name as you would any other value. You can also reference control properties and other values from throughout your app. For more details, see the examples below and working with record scope.

Split 函数可用于将字符串拆分成子字符串表。Use the Split function to split a string into a table of substrings.

Concatenate 函数可将混合的单独字符串和单列表中的字符串连接起来。The Concatenate function concatenates a mix of individual strings and a single-column table of strings. 这个函用于单独字符串时等同于 & 运算符Used with individual strings, this function is equivalent to using the & operator. 你可以使用包含 ShowColumns 函数的公式,将包含多列的表创建一个单列表。You can use a formula that includes the ShowColumns function to create a single-column table from a table that has multiple columns.

语法Syntax

Concat( Table, Formula )Concat( Table, Formula )

  • Table - 必需。Table - Required. 要运算的表。Table to operate on.
  • Formula - 必需。Formula - Required. 要对表中的记录应用的公式。Formula to apply across the records of the table.

Concatenate( String1 [, String2, ...] )Concatenate( String1 [, String2, ...] )

  • String(s) - 必需。String(s) - Required. 单独字符串或单列表中字符串的混合形式。Mix of individual strings or a single-column table of strings.

示例Examples

ConcatConcat

  1. 添加“按钮”控件,并将其 OnSelect 属性设置为以下公式:Add a Button control, and set its OnSelect property to this formula:

    Collect(Products, {String:"Violin", Wind:"Trombone", Percussion:"Bongos"}, {String:"Cello", Wind:"Trumpet", Percussion:"Tambourine"})Collect(Products, {String:"Violin", Wind:"Trombone", Percussion:"Bongos"}, {String:"Cello", Wind:"Trumpet", Percussion:"Tambourine"})

  2. 按 F5,单击按钮,然后按 Esc 键返回设计工作区。Press F5, click the button, and then press Esc to return to the design workspace.
  3. 添加一个“标签”控件,然后将“Text”属性设置为以下公式:Add a Label control, and set its Text property to this formula:

    Concat(Products, String & " ")Concat(Products, String & " ")

    这个标签会显示 Violin CelloThe label shows Violin Cello.

ConcatenateConcatenate

  1. 添加一个“文本输入”控件,然后将它命名为“AuthorName”。Add a Text input control, and name it AuthorName.
  2. 添加一个“标签”控件,然后将“Text”属性设置为以下公式:Add a Label control, and set its Text property to this formula:
    Concatenate("By ", AuthorName.Text) Concatenate("By ", AuthorName.Text)
  3. AuthorName 中输入你的姓名。Type your name in AuthorName.

    这个标签会显示 By,后跟你的姓名。The label shows By followed by your name.

如果有一个 Employees 表,其中包含 FirstName 列和 LastName 列,以下公式会将这两列中每一行的数据串联起来。If you had an Employees table that contained a FirstName column and a LastName column, this formula would concatenate the data in each row of those columns.
Concatenate(Employees.FirstName, " ", Employees.LastName)Concatenate(Employees.FirstName, " ", Employees.LastName)