chunk function. String.(Power Automate Cloud flows)

Japanese version.

The chunk function divides a single text into an array of equal-sized texts.

The chunk function has a collection function of the same name. It divides an array into multiple arrays of equal size.

Spec

chunk('<collection>', '<length>')
ArgumentDefaultDescription
collectionRequired fieldSpecifies the text to split.
lengthRequired fieldSpecifies the size of the division.

How to use

In many cases, it is used to initialize or set variables of type "Array".

Clicking on chunk in the "Expression" tab sets the function name and () in the formula field.

If you see something like the following, your settings are complete.

You can change the contents of the function by clicking on the purple icon.

When dynamic content or variables are used in expressions, special specifications are required.

(How to get dynamic content with expressions.)

Examples of arguments and results

For example, prepare a 9-character text, "ABCDEFGHI". The variable name is "srcText".

Divide "srcText" by 3 in length.

chunk(variables('srcText'),3)

The result is an array of text items.

[ 'ABC' , 'DEF' , 'GHI' ]

The "length" need not be divisible by the number of characters in the "collection".

A "srcText" with 9 characters can be divided by length 5.

chunk(variables('srcText'),5)

The result will be an array like this The last number of characters is cut off in the middle and becomes 4.

[ 'ABCDE' , 'FGHI' ]

How to use the results.

Set the result of the function "Apply to each" to "Select an output from previous steps".

In this example, the variable is named "dstArray" and the contents are as follows.

[ 'ABC' , 'DEF' , 'GHI' ]

In this example, "Apply to each" is repeated three times.

The "Current item" of dynamic content would look like this

  1. ABC
  2. DEF
  3. GHI

For those who want to learn Power Automate Cloud flow effectively

The information on this site is now available in an easy-to-read e-book format.

Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.

By the end of this book, you will be equipped with the knowledge you need to use Power Automate Cloud flow to streamline your workflow.

Links

String Functions(Power Automate Cloud flows)