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 / Moving Gallery Items o...
Power Apps
Answered

Moving Gallery Items only works if ID is greater

(0) ShareShare
ReportReport
Posted on by 21

Hi all!

I have a gallery that I have added up and down arrows to to facilitate shifting the order. The gallery is a collection from a Sharepoint list. On the up arrow's OnSelect I have: 

Select(Parent);Set(previousRecord,LookUp(KeyAreaOrder,Order=ThisItem.Order-1));Set(currentRecord,LookUp(KeyAreaOrder,Order=ThisItem.Order));Patch(KeyAreaOrder,ThisItem,{Order:previousRecord.Order});Patch(KeyAreaOrder,LookUp(KeyAreaOrder,Order=currentRecord.Order),{Order:previousRecord.Order+1});Set(previousRecord,Blank());Set(currentRecord,Blank())

 The first number column is the 'Order' column and the second is the ID

dfarrar_0-1626741985003.png

It works if the ID of the selected item is greater than the one above it, but not if the ID is less than.

Any ideas?

Thanks!

Categories:
  • Verified answer
    StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @dfarrar 

     

    ItemOrder = Order Column in my SP list

     

    Select(Parent);
    Set(
     currentRecord,
     LookUp(
     'Key Aisle',
     ItemOrder = ThisItem.ItemOrder
     )
    );
    Set(
     CurrentItemOrder,
     currentRecord.ItemOrder
    );
    If(
     CurrentItemOrder > 1,
    
     Set(PreviousId, LookUp(
     'Key Aisle',
     ItemOrder = currentRecord.ItemOrder - 1
     ).ID);
     Patch(
     'Key Aisle',
     ThisItem,
     {ItemOrder: currentRecord.ItemOrder - 1}
     );
     Patch(
     'Key Aisle',
     LookUp(
     'Key Aisle',
     ID = PreviousId
     ),
     {ItemOrder: currentRecord.ItemOrder}
     );
     
    );
    Set(
     currentRecord,
     Blank()
    )

     

     

    Sample

    StalinPonnusamy_0-1626758200807.png

     

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

  • dfarrar Profile Picture
    21 on at

    Hi @StalinPonnusamy 

    That has worked, but I also want to change the order number for the record above so that I don't end up with multiple records with the same order number.

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 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard