This Power Automate tutorial explains how to use the Power Autoamte Chunk() function, its syntax, and a few examples of how to use the chunk() function in Power Automate.
The Power Automate chunk() function will break the string into equal parts based on the provided length. If the string remains with any extra characters, then the remaining characters will also considered as one chunk.
Power Automate Chunk() Function
Under the string functions that have been used in Power Automate, the chunk() function will break the string into equal parts based on the provided length. It will also split an ‘Array’ into equal halves.
It will also calculate and include spaces while separating the string into equal sizes. If the string is left with extra characters, the remaining characters will also be considered one part.
Aside from it, Chunk() can also be used to convert a string to an array in Power Automate.
Power Automate Chunk() Function Syntax
This chunk() function syntax can be used inside a Power Automate flow.
Syntax: chunk('<String>', <length>)
It returns the output as an array with the text provided in particular defined sizes.
- String: The text string that should be divided into equal sizes.
- Length: It should be in the form of an integer, which results in the size of chunks.
Example: chunk(‘[Lynne Robbins]’,3) => It returns the output in the form of [“Lyn”, “ne “, “Rob”, “bin” ”s”].
Power Automate Chunk() Function Examples
Based on the examples of Power Automate flows, I will discuss how to use the Power Automate ‘string’ chunk function() inside a flow.
To implement the chunk() function inside a flow, Open the Power Automate home page; let’s create an ‘Instant cloud flow’ that will trigger manually.
Follow the below steps:
1. Open the Power Automate home page, click +Create, select ‘Instant cloud flow, ‘ give the flow a name, and select ‘Manually trigger a flow. ‘ Then click Create.
Click on +Add an input -> Select Text to provide text manually inside the trigger.
2. Under the flow trigger, add an ‘Initialize variable’ flow action to store the text value during the flow. Set parameters like Name, Type, and Value as shown below.
3. Then, add a ‘Compose’ data operation to add the chunk() function expression in the inputs section as placed in the code below.
4. Now, it’s time to save and test the flow Manually. Click on Save and Test. In the Run flow window, provide the text value in the box to test it. Click on Runflow.
5. When the flow runs successfully, it will display the array of equal chunks from the provided text as shown below:
This is how to use the string chunk() function inside a Power Automate flow to get equal parts of a text string.
In this example, I will explain another example of the Power Automate chunk() function based on the SharePoint list.
Here, I will take an example of ‘Automated cloud flow’ that will connect to the SharePoint list.
Now, we will use a SharePoint list named ‘ Medical Camp Registration’ to implement a chunk() expression on ‘Policy Code’ with a Single line of text (Title) datatype.
Similarly, follow the below steps:
1. Open the Power Automate home page and click on +Create. Select “Automated cloud flow” and provide a flow name. Choose the” When an item is created ” trigger and click on Create. Then select the site address and list name.
2. Under that, ‘Initialize a variable’ of the SharePoint list column, so that it will store the values of that column during the flow. Add the details like:
- Name: Give a name for an initialized variable.
- Type: Select the datatype from the drop-down.
- Value: Take value from the dynamic content.
3. Finally, add the ‘Compose’ data operation to provide a chunk() expression along with the variable.
4. Now, the flow is ready to save and test. So, click on Save and then Test it. Test the flow Manually.
At this step, add a new list item to the SharePoint list.
5. Open the ‘Compose’ data operation to check the output returned from the chunk() expression.
This is how to use Power Automate’s chunk() function expression to split strings into equal chunks.
I hope you understand how to work with the ‘Power Automate chunk() function‘ to split the string or an array into equal chunks. We saw how to trigger a manual trigger flow to get the string chunks in Power Automate. I have also shown you Power Automate splits a string into chunks in a SharePoint list using the chunk() function.
You may also like:
- Power Automate Contains() Function
- Power Automate toLower() Function
- Power Automate LastindexOf() Function
- Power Automate IndexOf() Function
- Power Automate toUpper() Function
- Power Automate substring() Function
- Power Automate formatNumber() Function
Preeti Sahu is an expert in Power Apps and has more than 6 years of experience working with SharePoint and the Power Platform. As a Power Platform expert for Power BI, Power Apps, Power Automate, Power Virtual Agents, and Power Pages, she is currently employed with TSinfo Technologies. She is the author of the book Microsoft Power Platform A Deep Dive. She also made a big technical contribution to SharePointDotNet.com in the form of articles on the Power Platform. She enjoys traveling and spending time with her family in her spare time.