Data manipulation in power automate
Hi
I have array of values like [1,2,3,4,5,8,10,11,12,13,14,15]. i should frame this array in a string like 1-5,8,10-15 in power automate. Any help would be appreciated. Thanks in Advance!
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
parthasarathy BPosted Mar 5, 2025, 4:31 AM
Thanks for your time @Eliana Blake.
It's throwing error for me oin the compose action like Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'union' expects either a comma separated list of arrays or a comma separated list of objects as its parameters. The function was invoked with '1' parameter(s). Please see https://aka.ms/logicexpressions#union for usage details.'.
In the union function only one parameter is passed.can you please check this once.
Eliana BlakePosted Mar 5, 2025, 3:38 AM
It's great to hear about your interest in Data manipulation in Power Automate!
To address your specific requirement of framing an array of values like [1,2,3,4,5,8,10,11,12,13,14,15] into a string format like 1-5,8,10-15 in Power Automate, you can achieve this through a combination of actions and expressions.
Here's a simple step-by-step guide to assist you in achieving this:
1. Use the "Initialize variable" action to create a string variable to hold the final formatted output.
2. Utilize the "Compose" action to insert an expression for parsing and formatting the array. You can use the following expression:
3. Next, use the "Replace" function within an expression to replace consecutive numbers with a dash ("-") to represent a range. Here's an example expression you can use:
4. Lastly, you can assign the final formatted string to your previously initialized variable.
By following these steps, you should be able to convert your array of values into the desired string format using Power Automate.
I hope this explanation assists you in achieving your objective. If you have any further questions or need additional clarification, feel free to ask. Good luck with your Power Automate data manipulation!