web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create a gallery from ...
Power Apps
Unanswered

Create a gallery from more than one set of comma delimited string

(0) ShareShare
ReportReport
Posted on by 271

I am returning three sets of comma delimited strings from Microsoft Flow to PowerApps. I can't return an array or complex object because of the nature of the Respond to PowerApps function. Let's say my three strings like like this: 

 

australia, germany, usa, new zealand

440,308,349,299

one,two,three,four

 

Each set of strings will always have the same amount of values in them, so 4, 4 and 4. Is there any way to somehow combine these together to bind to a Gallery? So I can have. 

 

Gallery Item 1: 

- Australia 

- 440

- one 

 

Gallery Item 2: 

- Germany

- 308

- two

 

and so on? I'm hoping there is. (This is all from tryng to get nested XML elements back from Flow to PowerApps in order to build a set of on-screen elements based on the info). 

Categories:
I have the same question (0)
  • JamesM Profile Picture
    271 on at

    The closest I've come is splitting each string and using that split as a column in a new collection, 

     

    Set(offers,GetMemberSisterClub.Run("2701126726055")); ClearCollect(offerNames,Split(offers.offername,","));ClearCollect(offerExpiries,Split(offers.expiry,",")); Collect(
     OfferList,
     {
     OfferName: Split(offers.offername,","),
     OfferExpiry: Split(offers.expiry,",")
     }
    )

     

    But it produces columns that have a table inside them, instead of columns of individual values for each row.

     

    2019-02-13 16_15_07-LoveMyLoyalty - Saved (Unpublished) - PowerApps.png

  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    Hi @JamesM

    This might not be the answer you're looking for, but I think it would be easier if you could modify your Flow so that it returns the results in a 'tabular' layout that you can bind to your Gallery.
     

    @Mr-Dang-MSFT wrote a great article on how to output JSON from the 'Respond to PowerApps' function in Flow. I think it's worth trying the same technique.

     

    https://powerapps.microsoft.com/en-us/blog/return-an-array-from-flow-to-powerapps-response-method/

     

    Also, @ericonline posted a similar question the other week. Perhaps Eric might be able to share how he worked around this issue.

     

    https://powerusers.microsoft.com/t5/General-Discussion/Collecting-Part-of-Another-Collection/m-p/211565#M67532

     

     

  • Verified answer
    Mr-Dang-MSFT Profile Picture
    on at

    O I love problems like this!

     

    Big idea here is that every nth record lines up among the 3 tables--knowing this is going to help us.

     

    There is no way to unite them out of the box. You'll need to bring them together with a repeated action. And when I think of repeated actions, I think of ForAll().

     

    Below is the formula I'm suggesting:

     

    Clear(joint_collection);
    
    ForAll(any_table,
     Collect(joint_collection,
     {
     column1: Last(FirstN(Split(string1,","),CountRows(joint_collection)+1)).Result,
     column2: Last(FirstN(Split(string2,","),CountRows(joint_collection)+1)).Result,
     column3: Last(FirstN(Split(string3,","),CountRows(joint_collection)+1)).Result...
     }
     )
    )

     

     

    Let's take this apart.

    • string1, string2, string3 are the strings that are returned from your flow (offers.__)
    • joint_collection is the collection that you want to result by bringing together the respective field from each string
    • any_table could be any one of the split strings since it's just used for determining how many times to loop/repeat the actions, ex: Split(offers.___,",")

     

     

    Clear(joint_collection);
    
    ForAll(any_table,
     Collect(joint_collection,
     {
     column1: Last(FirstN(Split(string1,","),CountRows(joint_collection)+1)).Result,
     column2: Last(FirstN(Split(string2,","),CountRows(joint_collection)+1)).Result,
     column3: Last(FirstN(Split(string3,","),CountRows(joint_collection)+1)).Result...
     }
     )
    )
    • Red: you already know this part. It's splitting up each string returned from flow.
    • Blue: each time these actions run, one more record is added to the join_collection.

      So this is getting the first n number of records from the split up strings as a table (FirstN). Last() picks the last of that subset. The Last(FirstN()) pattern gets you the nth record from a table.

      It gets the first record from all split strings and puts them into a row (empty collection+1).
      Then it gets a second record from all split strings and puts them into a row (1+1).
    • Green: Result is the default name of the column that results when you split up strings. You can wrap the entire thing around with Value if you need it to be a number or Text() if you need to format dates and times, etc.
  • JamesM Profile Picture
    271 on at

    Hi everyone, thank you so much for all the great responses, including @Mr-Dang-MSFT and @timl. Your suggestions combined with a couple of other threads here allowed me to settle on the following which has allowed me to iterate through each collection and combine them into a single collection for use in the gallery! This is part of what I love about PowerApps, you're unlikely to find many communities as eager to share and collaborate to bring about success for everyone as creators! <3!

     

    Set(
     offers,
     GetMemberSisterClub.Run("2701126726055")
    );
    ClearCollect(
     offerNames,
     Split(
     offers.offername,
     ","
     )
    );
    ClearCollect(
     offerExpiries,
     Split(
     offers.expiry,
     ","
     )
    );
    ClearCollect(
     offerAvailBalances,
     Split(
     offers.availbalance,
     ","
     )
    );
    ClearCollect(
     offerOpenBalances,
     Split(
     offers.openingbalance,
     ","
     )
    );
    ClearCollect(
     counter,
     0
    );
    Clear(Combined);
    ForAll(
     offerNames,
     Collect(
     counter,
     Last(counter).Value + 1
     );
     Collect(
     Combined,
     {
     offerAvailBalances: Last(
     FirstN(
     offerAvailBalances,
     Last(counter).Value
     )
     ).Result,
     offerOpenBalances: Last(
     FirstN(
     offerOpenBalances,
     Last(counter).Value
     )
     ).Result,
     offerNames: Last(
     FirstN(
     offerNames,
     Last(counter).Value
     )
     ).Result,
     offerExpiries: Last(
     FirstN(
     offerExpiries,
     Last(counter).Value
     )
     ).Result
     }
     )
    )

    While this is working great, I do look forward to being able to return more complex types from Flow to PowerApps, such as JSON, XML or other easily serializable / de-serializble data formats 🙂  Below is my current UI, the gallery will be the recipient of this data set allowing customers to navigate through their available loyalty offers 🙂  (And yes, the pink is intentional, it's part of the brand 🙂Untitled.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard