How to convert a List<List<double>> to a DataTable?

Hi All,

I am struggeling with the following problem.

In my workflow I am creating a list with all posible combinations of a list of doubles values. I want to sum up all possible combinations and check the all of the total values with a target value. To do this I want to convert it to a datatable with a set number of colums so that the summation is easier.

Finding the list of combinations works fine, but now i want to set this list<list to a datatable, but I im having no luck yet, does anyone has a idea how to do this with Code or if thats not possible with activities?

So i start with for example List {3.54,4.56,5}

The result is:
List
{3.54,4.56,5}
{3.54,4.56}
{3.54,5}
{4.56,5}
{5}
… and so on.

I would like to convert this list to a DataTable.

Any thoughts?

Hope to hear from you.

John

I’m not sure I understand why you want to convert it to a datatable. Seems like an unnecessary extra step. Couldn’t you just loop through the list and do the checking you need?

Hi Paul,

So that I can use the sum fuction without a loop and sum up all the values at once and use the lookup datatable to find a match with my target value.
The numbers get big fast with getting combinations, so I mostly want to avoid using loops.

If you have any other Ideas on how to get this done, that would also be great aswell.

What are you expecting the datatable to look like as far as rows and columns?

I will put a max to the amount of input, so lets say 16 columns and then the sum at column 17.
The rows need to be populated with the values of all of the combination values(array’s). Position within the row does not matter because I will sum up these values.

have a look here:
grafik

Thanks Peter, Could you elaborate on this, because i both need the total of the sub array and the values within the sub array. Then I can match the sub values with the target value and later reuse these value in the following proces. That is why I wanted to put it into a Datatable, so that i can just simply filter the table and have them all on the same row. Could you share your workflow? thanks!

sure
lets assume the list is used:

As far I do understand you need: you need a datatype / Structure offering for each List item:

  • the array items
  • the sum of the array items

Maybe A dictionary along with tuples can serve it:
grafik
grafik

and will allow:
grafik
Line1 - the dict
Line2 - Access first element
Line3 - access the sum of first subarray
Line4 - access the first subarray

Find starter help here:
ListDoubleArray_ToSumDict.xaml (5.4 KB)

2 Likes

Hi Peter,

I’ve now got the dict. variable with all the sums of the arrays as you’ve showed in the provided workflow.

Perfect thanks so much! Now I only need to find the matching value in the dict. is there a function for this so i know which item in the dict. total value matches and which array values belong to that sum?

Hope to hear from you, very helpfull!

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