cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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

Re: Help! not able to sort based on column priority

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

Highlighted
Community Support
Community Support

Re: Help! not able to sort based on column priority

Hi @anmol_05 ,

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

Re: Help! not able to sort based on column priority

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

Highlighted
Frequent Visitor

Re: Help! not able to sort based on column priority

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

Highlighted
Super User III
Super User III

Re: Help! not able to sort based on column priority

@anmol_05 

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

Highlighted
Frequent Visitor

Re: Help! not able to sort based on column priority

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

Highlighted
Super User III
Super User III

Re: Help! not able to sort based on column priority

@anmol_05 

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

Highlighted
Frequent Visitor

Re: Help! not able to sort based on column priority

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

Highlighted
Super User III
Super User III

Re: Help! not able to sort based on column priority

@anmol_05 

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

Highlighted
Frequent Visitor

Re: Help! not able to sort based on column priority

@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

Highlighted
Super User III
Super User III

Re: Help! not able to sort based on column priority

@anmol_05 

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (3,227)