cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
neill_long
Helper V
Helper V

Collection and if statement

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

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@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"

)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

7 REPLIES 7
CNT
Super User
Super User

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

RandyHayes
Super User
Super User

@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.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
neill_long
Helper V
Helper V

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
Super User
Super User

@neill_long 

Your Gallery would be valid with the following formula:

 

If(

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

    "Correct"

)

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@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?

RandyHayes
Super User
Super User

@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"

)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes brilliant, thanks very much for your help

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,242)