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 / Sorting/Add Columns Sy...
Power Apps
Answered

Sorting/Add Columns Syntax Question

(0) ShareShare
ReportReport
Posted on by

Hello,

 

Yesterday I was working on adding sorting capability to my gallery. I got it all working, but when I clicked my Gallery nav button, PowerApps was no longer able to display my forms (see BlankForm.png). I think I know what happened. I replaced the name of my SharePoint list which is 'Tool Design Support Requests' in the Gallery Items formula with the name of the Collection I used to add columns for the sake of sorting in my Gallery Items formula. If I try switching it to the name of the SharePoint list, the formula breaks. 

 

Gallery Items Formula:

SortByColumns(

    Filter(colRequests,

        StartsWith(

            Title,

            TxtSearchBox.Text

        ) && (ddStatus.Selected.Value = "Status All" || Status.Value = ddStatus.Selected.Value)

    ),

    conSort,

    If(

        SortDescending,

        Ascending,

        Descending

    )

)

 

App OnStart Collection:

ClearCollect(colRequests,AddColumns('Tool Design Support Requests',"StatusTxt",Status.Value,"AuthorTxt",Author.DisplayName,"PMTxt",PMPEPerson.DisplayName,"METxt",MEAssigned.DisplayName,"PCTxt",PercentComplete.Value)

 

The reason I added columns to the Collection was that I had a number of complex column types I wished to sort on. The data source for the forms is the Tool Design Support Requests SharePoint list and I would really like to keep it that way. I had all of the forms working before and I really like the ability to sort the gallery (see SortedGallery.png) so PLEASE tell me this is something easy to fix. I greatly appreciate you taking a look at it for me!

 

Teresa

SortedGallery.png
BlankForm.png
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,918 Most Valuable Professional on at

    Hi @tagustin2020 ,

    The reason is fairly simple, you cannot base a form on a collection, it must be based on a list. You can still have have your gallery to sort on the new fields, but the form just needs to based on 'Tool Design Support Requests' as the Data Source. The easiest way to set the Item would be

    Lookup(
     'Tool Design Support Requests',
     ID=YourGalleryName.Selected.ID
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @tagustin2020 

    Most likely the problem is in the Item property of the form.  If the Items property of the gallery is different from the Item property of the form, the item property of the form must be changed to something like

     

    Lookup(datasource,ID=Gallery1.Selected.ID)

     

    The datasource of the Lookup must match the datasource of the form.   

  • tagustin2020 Profile Picture
    on at

    @WarrenBelz @Drrickryp 

     

    Thank you both for the prompt replies. My current OnSelect Formula for my Gallery nav button is:

     

    Set(varRecord,ThisItem);Navigate('Edit Request Screen',Transition.None)

     

    My Item reference for each form used to be varRecord. I changed the Item formula for each form to what you suggested and they are back in business so thank you(!), but is having varRecord on the nav button going to mess things up? Do I need to change it to something else? It seems to be working for now, but I'm not sure I trust it...

     

    Thanks,

    Teresa

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @tagustin2020 

    It is unnecessary but it won't do any harm.  You could even use it in the lookup formula.

    Lookup(datasource,ID=varRecord.ID)
  • tagustin2020 Profile Picture
    on at

    Great! Thanks for showing me how to incorporate the variable into the formula. I can rest much easier now that everything is working again 🙂

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard