web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sorting Power Apps Gal...
Power Apps
Unanswered

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!

I have the same question (0)
  • Verified answer
    Ami K Profile Picture
    15,674 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,674 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 802 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 332 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 273

Last 30 days Overall leaderboard