cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Help! not able to sort based on column priority

Hi, I'm very new to powerapps.... I just wanted to know if there is any way to sort results in the gallery on column preference after filtering my SharePoint list based on 3 text columns namely domain, description, use. Like, I want to display the results that matched the domain column above the results that matched the description, and so on... And I'm using 'in' to match records through filter.

i.e.

Filter(Mylist,InputText1.Text in Domain ||InputText1.Text in Description||InputText1.Text in Use)

Please Help very urgent...

2 ACCEPTED SOLUTIONS

Accepted Solutions
mdevaney
Super User
Super User

@Anonymous 
The code would look like this.

 

SortByColumns(
    AddColumns(
        Filter(Mylist,InputText1.Text in Domain ||InputText1.Text in Description||InputText1.Text in Use),
        "isDomain", InputText1.Text=Domain,
        "isDescription",  InputText1.Text=Description,
        "isUse", InputText1.Text=Use
    ),
    "isDomain", Ascending,
    "isDescription", Ascending,
    "isUse", Ascending
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Hi @Anonymous ,

The reason why you got error like that is :

If you set the gallery's Items to AddColumns(MyList,....)

Then the gallery's data source will not be Mylist, it will become the new table: AddColumns(MyList,....).

So "Gallery.Selected" will represent an item in this table: AddColumns(MyList,....), not an item in MyList.

However, since you set the view form and edit form's data source to Mylist, so you could not directly use Gallery.Selected to their Item.

The view form and edit form's data source and Item should point to the same table.

 

The solution is: using the unique id field in Gallery.Selected to filter MyList, get the related item in MyList.

 

Try to set the view form and edit form's data source: MyList.

Item: 

LookUp(MyList,ID=BrowseGallery1.Selected.ID)

 

 

 

Best regards,

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

14 REPLIES 14
mdevaney
Super User
Super User

@Anonymous 
The code would look like this.

 

SortByColumns(
    AddColumns(
        Filter(Mylist,InputText1.Text in Domain ||InputText1.Text in Description||InputText1.Text in Use),
        "isDomain", InputText1.Text=Domain,
        "isDescription",  InputText1.Text=Description,
        "isUse", InputText1.Text=Use
    ),
    "isDomain", Ascending,
    "isDescription", Ascending,
    "isUse", Ascending
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Anonymous
Not applicable

@mdevaney  Thanks for the solution... Let me try this .... but I still didn't understand why we have to add columns ... Could it be done by assigning a value and then sorting...like

Sort(Filter("Same data"),If(result in Domain, 1000,0)+If(Result in Description, 100,0)+If(Result in Use, 10,0), Descending )

@Anonymous 

Suggest you try the solution first and let me know if it worked.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Anonymous
Not applicable

@mdevaney  The solution you gave, gave an error in sort by columns, it said IsDescription doesn't exist and similar for the other two columns ... I still can't understand why the error is coming...

@Anonymous 

isDecsription probably has a typo or something.  Please fix it and then take a screenshot of your code if its still not working 🙂 

Anonymous
Not applicable

@mdevaney  Thanks, cleared that now I'm getting error on my form viewer screen and form edit screen

@Anonymous 

Please take a screenshot of the formula you wrote alongside the error message.

Anonymous
Not applicable

@mdevaney ....These are the screenshots and thanks for the help

the error message is:

Invalid formula, expected a value compatible with data source; on the detail screen

@Anonymous 

From the screenshot it looks like I solved the main question you asked here.  Now you are talking about something different in an Edit Form.  You’ll have to write a Lookup function to pull in the record in the Item property instead of relying on Gallery.Selected.

 

I’m going to get some sleep and respond in the morning.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,937)