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 Power Apps Gal...
Power Apps
Answered

Sorting Power Apps Gallery using Dataverse

(0) ShareShare
ReportReport
Posted on by 6

Hi,

 

I'm trying to sort a gallery with Dataverse as a data source.

 

I added a sort icon and used the below function in OnSelect property.

 

UpdateContext(
{
ctxSortDescending: !ctxSortDescending
}
)

 

Used the below code in gallery Items property.

 

SortByColumns(
Filter(
'Requests',
Status = TabsGallery_1.Selected.Value && Support = Dropdown1.Selected.Value || TicketStatus = Dropdown2.Selected.Value
),
crc0a_name,
If(
ctxSortDescending,
SortOrder.Descending,
SortOrder.Ascending
)
)

 

I'm getting "Name isn't valid. 'crc0a_name' isn't recognized." error. Does anyone have suggestions on how to fix this issue? I also need to sort text, number and date columns.

 

Thank you so much!

  • Verified answer
    Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    Hi @anut12,

     

    On the OnSelect property of your icon, enter the following for Date: 

     

     

    UpdateContext({AppSortAscending: !AppSortAscending});
    UpdateContext({SortColumn: "datecolumn"}) //your logical date column name

     


     On the OnSelect property of another icon, enter the following for Text: 

     

     

    UpdateContext({AppSortAscending: !AppSortAscending});
    UpdateContext({SortColumn: "textcolumn"}); //your logical text column name

     


    On the OnSelect property of another icon, enter the following for Number:

     

     

    UpdateContext({AppSortAscending: !AppSortAscending});
    UpdateContext({SortColumn: "numbercolumn"}); //your logical number column name

     

     

    Now enter the following in the Items property of your Gallery:

     

     

    Sort(
     Filter(
     'Requests',
     Status = TabsGallery_1.Selected.Value,
     Support = Dropdown1.Selected.Value || TicketStatus = Dropdown2.Selected.Value
     ),
     Switch(
     SortColumn,
     "textcolumn",
     'Text Column',
     "datecolumn",
     'Date Column',
     "numbercolumn",
     'Number Column',
     'Modified On'
     ),
     If(
     AppSortAscending,
     SortOrder.Ascending,
     SortOrder.Descending
     )
    )

     

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution

    If you like my response, please give it a Thumbs Up.

  • anut12 Profile Picture
    6 on at

    Thanks for your help @Amik 

     

    I tried to use the same code for Lookup column but it doesn't work. Is there a different code for Lookup columns?

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @anut12 your welcome.

     

    The same principle applies to Dataverse Lookup columns if they are single choice. What do you mean when you say it doesn't work? Is there an error?

     

     

  • anut12 Profile Picture
    6 on at

    Sorry, I didn't mention the error before. I do get an "Invalid Argument Type" error. The lookup columns are single choice.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard