0

I am building an Azure Data Factory. Inside a Data Flow I have an array of strings.

That array of strings I wish to merge into one single string.

ie. [ "value1", "value2" ] into "value1, value2"

Is that even possible, I can´t find any function helping me out here?

I wish there existed a join function or foreach but can't find any?

Per
  • 1,393
  • 16
  • 28

3 Answers3

1

Here you go:

dropLeft(toString(reduce(['value1','value2','value3','value4'], '', #acc + ', ' + #item, #result)), 2)

Results:

value1, value2, value3, value4
0

Does toString(myArray) do what you are looking for?

Mark Kromer MSFT
  • 3,578
  • 1
  • 10
  • 11
  • 1
    YES! And no. I did not realize toString actually works on arrays as well. So, this is part of my solution, followed by a couple of replaces as I need to clean it up. Thanks. – Per May 24 '22 at 07:25
-1

You can use the join function which is present in collection functions in Add dynamic content.

enter image description here

Syntax:

join([<collection>], '<delimiter>')

Example:

join(variables('ARRAY_VARIABLE'), ',')

Refer this to learn more about the Join.

Also, you can do it by using a ForEach loop activity to iterate over the array and use a Set Variable task with a concat expression function to create the comma separated string.

In case, you just have two elements in your array, then you can do like this.

@concat(variables('variable_name')[0].Code1, ',', variables('variable_name')[1].Code1)
Rakesh Govindula
  • 5,257
  • 1
  • 2
  • 11
  • The foreach does only exist in Pipeline, not in Data Flow. Neither is join available as part of the Aggregate schema modifier which I need to use in this case – Per May 23 '22 at 12:07