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 / Collection and if stat...
Power Apps
Answered

Collection and if statement

(0) ShareShare
ReportReport
Posted on by 728

Hello,

 

I have a gallery which is connected to a collection.  Within the gallery, the user is able to re-arrange the items by clicking on the up or down button.  by doing this, the "Order" field in the collection updates to whichever position the user has moved the item to.

 

There are 6 items in total.  This is for a reorder question and the items have to be put in a specific order.

 

I am trying to write an if statement which would show me the following:

 

If collection (Reorder), Name field = "Beginning" and Order field = 1, and Name field = "Planning" and Order field = 2 and so on, this would be correct.

 

How would I write this in a text box?

 

thanks

Alistair

Categories:
  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @neill_long Could you pls share some screen shots & formulas that to have currently to understand your situation better.

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

    @neill_long 

    Can you expand a little more on what role the Name field has in the order of your items?  In general, it sounds like you are trying to provide a way to re-order the items in a list?

    Please share a little more to help with this.

     

  • neill_long Profile Picture
    728 on at

    Hi @CNT  & @RandyHayes 

     

    I was following this video by April Dunnan - https://www.youtube.com/watch?v=vuBuPxOY8uM

     

    The gallery displays the items in a mixed up order:

     

    CaptureA.JPG

    On the Up arrow, I have the formula:

     

    UpdateContext({previousRecord:LookUp(
     Reorder,
     Order = ThisItem.Order - 1)
    });
    Update(Reorder,
    previousRecord,
    {Name: previousRecord.Name,
    Order: ThisItem.Order
    }
    );
    Update(
     Reorder,
     ThisItem,
     {
     Name: ThisItem.Name,
     Order: previousRecord.Order
     }
    );

     

    On the down arrow, I have:

     

    UpdateContext({nextRecord:LookUp(
     Reorder,
     Order = ThisItem.Order + 1)
    });
    Update(Reorder,
    nextRecord,
    {Name: nextRecord.Name,
    Order: ThisItem.Order
    }
    );
    Update(
     Reorder,
     ThisItem,
     {
     Name: ThisItem.Name,
     Order: nextRecord.Order
     }
    );

     

    The collection, at the start, before re-arranging, looks like thisL

     

    Collection.JPG

     

    The ensure a correct answer, the user needs to have the items in this order:

     

    Capture1.JPG

     

    When the user clicks on the up or down option, the "Order" field updates as shown below:

     

    CollectionA.JPG

     

    I am then adding a label to the page where i want to specify if the user has put the items in the correct order.  I was thinking that i could put a formula:

     

    If(Reorder, Name = "Beginning" && Order = 1 & Name = "Planning" && Order = 2 & Name = "Preparation" && Order = 3 & Name = "Introduction" && Order = 4 & Name = "Main Ideas" && Order = 5 & Name = "Conclusion" && Order = 6, "Correct")

     

    I am probably completely wrong with what i have put previously but if you could help point me in the right direction that would be great.

     

    Hope this helps

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

    @neill_long 

    Your Gallery would be valid with the following formula:

     

    If(

        Concat(yourGallery.AllItems, Name & ";") = "Beginning;Planning;Preparation;Introduction;Main Ideas;Conclusion",

        "Correct"

    )

  • neill_long Profile Picture
    728 on at

    @RandyHayes 

    Added the formula but it doesn't seem to be working.  Here is the formula i have added:

     

    If(
    
     Concat(Gallery3.AllItems, Name & ";") = "Beginning;Planning;Preparation;Introduction;Main Ideas;Conclusion",
    
     "Correct", "Wrong"
    
    )

     

    As you can see from the image, the gallery items are in the order outlined in the formula:

     

    wrong.JPG

     

    Would you have any ideas why this would be displaying as wrong or can you suggest a solution?

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

    @neill_long 

    Sorry, forgot about the trailing semi-colon.

    Formula should be:

    If(
    
     Concat(Gallery3.AllItems, Name & ";") = "Beginning;Planning;Preparation;Introduction;Main Ideas;Conclusion;",
    
     "Correct", "Wrong"
    
    )
  • neill_long Profile Picture
    728 on at

    @RandyHayes brilliant, thanks very much for your help

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard