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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to Remove and Add ...
Power Apps
Answered

How to Remove and Add items in gallery. If items are split text.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all, 

 

I have got a column that collects a text with a delimiter ",". And I wanted to put this into a gallery and show as an Items and control that particular collection using Gallery features such as Remove. And then keep the updated one. 

 

Here's an example case. 

 

I have got a text or Data  that looks like this - Autodesk Civil 3D,Autodesk Map,Autodesk Plant 3D

 

And I have used Split function in PowerApps which results as show below -

 

Used logic  Split(approvingrequest.X_x002d_NotRelevant,",")

 

ashwnaidv100_0-1601458525707.png

 

I have taken this output as an item to my gallery. And I got something like this. and which is perfect.

ashwnaidv100_2-1601458800675.png

 

Now my question is how would i Remove and Add these particular item and still be able to get back get all the new texts. 

 

 

Any help and workaround would be really appreciated. 

 

Thanks you 

Ash

 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    I am not entirely clear on what you mean by adding and removing in this case.

    Are you saying that you want to be able to have new items added to the list, and conversely remove some items from the list?

     

    If so, you could do this by manipulating the source string of value that you are splitting.  However, this is most likely going to create a circular reference from your Gallery to the Gallery Items - which will not work.

     

    In this case, it might be best to create a collection based on the split of the string and use that as the Items property.  Then within your Gallery (or elsewhere) you could remove and add rows to that collection as needed.

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @RandyHayes , 

     

    Yes got it right. 

     

    I tried to collect my Split result into collection, It didn't go well. 

     

    Can you let me know how to do it as i tried to do it and got below error. 

    ClearCollect(approvalonlevel5, Split(approvingrequest.X_x002d_NotRelevant,",").Result)

    ashwnaidv100_0-1601477603777.png

     

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    First, change your formula to the following:

    ClearCollect(approvalonlevel5, Split(approvingrequest.X_x002d_NotRelevant,","))

    Next, this needs to be in an Action, such as an OnSelect or OnStart or OnVisible, etc.

    You cannot use it directly in the Items property. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @RandyHayes,

     

    Remove functionality work like a charm. 

     

    But I have having trouble with adding new data into the same collection. 

     

    I'm using Add button on which in its OnSelect property I'm using Patch function.

    I'm trying to Patch some SelectedItems from a ComboBox.

     

    Here a formula : Patch(approvalonlevel5, {Result: ComboBox3.SelectedItems.Software_name})

     

    But keep getting an error message from button which says :

    error1.PNG

     

    Can't understand why this is happening, as I don't wanted to push my data directly to database until/unless all the changes been made with this add and remove feature. 

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Yes, that is not a valid use of Patch for adding records (Patch does not add records).

    Consider the following formula instead:

    Collect(approvalonlevel5, {Result: ComboBox3.SelectedItems.Software_name})

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @RandyHayes ,

     

    I tried to put Collect instead of Patch, But got this error.

    Used code: Collect(approvalonlevel5, {Result: ComboBox3.SelectedItems.Software_name})

     

    ashwnaidv100_0-1601696610893.png

     

    Here some info that will help you to get clear understanding.

     

    From my original post I was using Split function to collect my data, now those Split value is collected in approvalonlevel5.

    I just wanted it to manipulate it as, we have got remove already working , now adding ComboBox SelectedItems is became pain.

     

    I also tried to Concat the selected items and to Patch it and it works fine, But I can't use Concat as I wanted to be added as a new items, not all in one.

     

    Hope this context will help to understand a bit better.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Sorry, I over looked something you had from your Patch formula that I should have changed in my last post.  Change formula to:

    Collect(approvalonlevel5, {Result: ComboBox3.Selected.Software_name})
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes ,

     

    Yes this solution actually work, as I mentioned it can be a multiple selection from the ComboBox which is leading it to this error. 

     

    I had tested this before. That's why said I can add only one item either by this or by Concat multiple selected item as one. 

     

    ashwnaidv100_0-1601825578966.png

    As you can see only last selected option has been added to gallery. 

     

    I think this logic is still might not the right approach. I can't think of work around.  

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    This seems quite different than what I had understood your issue to be with.  Perhaps it is a second part to the issue.

     

    Anyway, if you want to add all the selected items in the ComboBox to the Gallery, then consider changing your formula to this:

    ForAll(ComboBox3.SelectedItems,
     Collect(approvalonlevel5, {Result: Software_name})
    )

    That will add any items in the combobox selected into the collection by the Software_Name

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Great @RandyHayes , it working... I was writing the same but opposite, what I was trying ForAll inside the Collect (what a fool am I). 

     

    Perfect, This resolves the Issues. Thank you so much. Have a great day. 

     

    Marking your response as a Solution. 

     

    Cheers. 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard