cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Microsoft
Microsoft

How to split array into a datatable or html text box

I have an array that I store in a collection and currently I can dump the data into a data table.  I've been struggling on how I can split that array by ",".  I've tried the split function, but have had no success.  I'm also not entirely sure where the split function should be entered, either at the trigger (the button) or the datatable piece.

 

split(collection,",")

  

Screen Shot 2019-06-03 at 4.23.27 PM.png

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @robevans ,

Could you please share a bit more about the result the DEV_HSRedaction.Run() formula returns? Just like ["done", "done", "done", ...., "done"] (a string value)?

Do you want to split the ["done","done","done", ...] string value into an array into a Data Table?

 

Based on the needs that you mentioned, I think the combination of Substitute function and Split function could achieve your needs.

I have made a test on my side, please take a try with the following workaround:6.JPG

 

7.JPG

Set the Items property of the Data Table2 to following formula:

Split(
Substitute(
Substitute(
Substitute(
Substitute(First(datafromflow).Value, "[", ""),
"]",""
),
"'",""
),
" ",""
),
","
)

On your side, please set the Items property of the Data Table control to following:

Split(
      Substitute(
                  Substitute(
                               Substitute(
                                          Substitute(First(datafromflow).Value, "[", ""),
                                          "]",""
                               ),
                               "'",""
                  ),
                  " ",""
      ), 
      ","
)

More details about the Substitute function and Split function, please check the following article:

Substitute function, Split function

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Dual Super User III
Dual Super User III

Do you actually have an array or a comma delimited string stored in the collection.  When I create a collection using the following code I can bind the collection directly to the datatable and each array value becomes a row.

 

ClearCollect(mytable,["Test1","Test2","Test3"]) 

 

Can you provide a screen shot of what is in your collection after you load the array?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

So here's my button code that collects the data from Flow Array and also what my table looks like. 

 

 

Screen Shot 2019-06-04 at 2.15.30 PM.png

 

 

Screen Shot 2019-06-04 at 2.15.22 PM.png

 

Here's the body being sent over from Flow.

 

{
  "vardata": "[\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\",\"done\"]"
}

 

On second look the type is a String and not an array being sent from Flow.  This should still allow to split though?

Dual Super User III
Dual Super User III

Yes, it should allow split.  The issue may be how it interprets the string.  The escaped double quotes may still cause an issue.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi @robevans ,

Could you please share a bit more about the result the DEV_HSRedaction.Run() formula returns? Just like ["done", "done", "done", ...., "done"] (a string value)?

Do you want to split the ["done","done","done", ...] string value into an array into a Data Table?

 

Based on the needs that you mentioned, I think the combination of Substitute function and Split function could achieve your needs.

I have made a test on my side, please take a try with the following workaround:6.JPG

 

7.JPG

Set the Items property of the Data Table2 to following formula:

Split(
Substitute(
Substitute(
Substitute(
Substitute(First(datafromflow).Value, "[", ""),
"]",""
),
"'",""
),
" ",""
),
","
)

On your side, please set the Items property of the Data Table control to following:

Split(
      Substitute(
                  Substitute(
                               Substitute(
                                          Substitute(First(datafromflow).Value, "[", ""),
                                          "]",""
                               ),
                               "'",""
                  ),
                  " ",""
      ), 
      ","
)

More details about the Substitute function and Split function, please check the following article:

Substitute function, Split function

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thanks @v-xida-msft that worked for the most part.  Except the quotes are still present before and after done for me, but your screenshot is showing as removed.  Did I miss a step?

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,637)