cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
neill_long
Resolver I
Resolver I

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

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

7 REPLIES 7
CNT
Community Champion
Community Champion

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

RandyHayes
Super User III
Super User III

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
neill_long
Resolver I
Resolver I

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

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

@RandyHayes brilliant, thanks very much for your help

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (26,723)