How to update the values of an array variable with an additional string

Priya Jha 866 Reputation points
2023-01-30T10:06:06.94+00:00

How to update the values of an array variable with an additional string

 

Input : [l,m,n,o]

 

additionstring : abc

 

output : [abcl,abcm,abcn,abco]

 

How is it possible ?

Note: we do not want to use iteration activities

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,525 questions
0 comments No comments
{count} votes

Accepted answer
  1. MartinJaffer-MSFT 26,021 Reputation points
    2023-01-30T18:45:12.77+00:00

    @Priya Jha Hello and welcome to Microsoft Q&A.

    I understand you want to update an array variable in pipeline expression without using iteration.

    Since iteration is ruled out, the way to do this is cleverly turn the array to string to use replace function, concat function, and then split to turn it back into array again. Below is expression to do it.

    @split(concat(variables('additionstring'),join(variables('Input'),concat(',',variables('additionstring')))),',')
    
    1. join the input array together into a string using ("," + "abc") as separator -> "l,abcm,abcn,abco"
    2. concat "abc" to the beginning of the string -> "abcl,abcm,abcn,abco"
    3. split the string back into array, using "," as separator -> ["abcl","abcm","abcn","abco"] Let me know how it goes! Don't forget to mark as accepted answer if it solves your issue.

0 additional answers

Sort by: Most helpful