Convert data column to string

Hi,

I am having a datatable with two columns in string format. It can have any random data as below.

|Column1|Column2|
|Mercury | Venus|
|Neptune | Mars |
|Jupiter|Saturn|
|Uranus|Earth|

My flow will receive an int parameter and I have to concatenate those many rows of column 2.

Example1 : If flow receives 2 as parameter, then output would be “Venus,Mars”
Example2: If flow receives 4 as parameter, then output would be “Venus,Mars,Saturn,Earth”

It can be done using For loop, but wanted to check if there can be a better way of doing it(using linq?).

@Kapil Considering the Source Data is Column2, You can use Take method to take the number of rows as you need. Similar Linq Query is Given Below :

String.Join(",",DT.AsEnumerable.Select(Function(x)x("Column2").ToString).Take(intParameter))

Where DT is your Datatable variable and intParameter is the parameter that decides the number of values to be taken.

1 Like

Thanks!! It worked

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.