cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

Delete position from collection

Hello,

 

I have this function to add a position to collection:

 

Collect(colMyTaskList,1)

 

Is there a way to delete this particular position?

 

I use it on button and when I click it it shows a position in gallery. 

 

I tried this, but it failed:

Remove(colMyTaskList,Last(colMyTaskList))
1 ACCEPTED SOLUTION

Accepted Solutions

As I thought the problem with deleting last item is because all Values are the same.

 

When I changed my function to:

 

Collect( NewGUIDs, GUID() ) 

 

 

It delete well only last item. Because every item is unique.

I just do not know how to make it with Value + 1...

I want numbers 😞 1,2,3,4,5,6 

View solution in original post

8 REPLIES 8
Post Prodigy
Post Prodigy

Ok I didn't write it enough specifically:

 

Remove(colMyTaskList,Last(colMyTaskList))

 

This function works, but it does not delete last record but ONE Before last. 

LastN works in a same manner.

 

So if I have 3 rows.

 

1.XXX.

2. YYY.

3. ZZZ.

 

This button will delete number 2.

then if there are 

 

1.XXX

2.ZZZ

it will delete number 1.

Dual Super User
Dual Super User

@Elitezone 

 

Do you know the value which you want to remove from the collection but not the position?

 

If so, you can look up the collect to remove the value.

 

Remove(mySolution50a,LookUp(mySolution50a,Serial=4623));

 

Check @mdevaney  collections cookbook for more reference:

https://matthewdevaney.com/powerapps-collections-cookbook/remove-a-row-from-a-collection/

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

@rsaikrishna 

No. I only know that I want to remove LAST record from collection.

 

Worst part is that FIRST function work perfectly, but last one takes LAST minus 1 record always unless there is 1 record.

I tried your last formula but it works fine.

Please recheck your Table structure.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

@Elitezone 

 

Place a label on the screen and try displaying the value from Last(colMyTaskList).

 

With this, you will know which item you are getting. 

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

@rsaikrishna 

Expected text value error.

 

@eka24 

I use this collection in a gallery that has only two input boxes - Name, Description.

 

But what I save to collection is only value 1.

I think that I do not understand it.

 

One user helped me to set up such a gallery:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Right-field-to-gather-users-tasks/m-p/732155...

 

it uses collection that stores this data:

Elitezone_0-1603975221970.png

Input data is not stored in gallery because it should patch later to sharepoint list.

I have no idea if it will work correctly, since collections is a black magic for me (even tho I read a lot about them).

 

Basicly,

1. I click ADD record button - it has function:

 

Collect(colMyTaskList,1)

 

This add new item to gallery and user can fill it.

If user makes a mistake he should be able to delete this item.

 

2. When user finish he click button and this button patch all data from input boxes to sharepoint list fields.

In theory maybe it will work.

 

3. My onVisible screen has parameter:

If(CountRows(colMyTaskList) = 0,ClearCollect(colMyTaskList,1))

This load one INITIAL task so the gallery is not empty.

 

I also tried to make unique value by doint this but this does not work, because I thought that maybe if there will be ID then it will work better:

 

 

Collect(colMyTaskList,(Last(colMyTaskList.Value+1)))

 

 

This also:

 

 

Collect(colMyTaskList, {Value:(Last(colMyTaskList.Value+1))})

 

 

and this as well:

 

Collect(colMyTaskList, Sum(Text(Last(colMyTaskList.Value)+1)))

 

As I thought the problem with deleting last item is because all Values are the same.

 

When I changed my function to:

 

Collect( NewGUIDs, GUID() ) 

 

 

It delete well only last item. Because every item is unique.

I just do not know how to make it with Value + 1...

I want numbers 😞 1,2,3,4,5,6 

View solution in original post

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 (9,436)