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 / How to sort gallery De...
Power Apps
Answered

How to sort gallery Descending with Nulls at top?

(0) ShareShare
ReportReport
Posted on by 25
 
 

I'm trying to sort a gallery based on 

DaysSinceLastVisit  //Number of days since last visit 

 

This column has a NULL if the location has no recorded visits

I'd like to force these locations to the top of the gallery.

 

Any suggestions?

Thanks

Steve

 

 

 

Sort(
Filter('[checklist].[HierarchyWithLastVisit]',(CM_Email=vCurrentUser.Email) &&
(StartsWith(StoreType,ThisType) &&
(StartsWith(StoreId,TextSearchBox_1.Text) ||
StartsWith(STORE_NAME, TextSearchBox_1.Text) ||
StartsWith(CITY, TextSearchBox_1.Text))
)),DaysSinceLastVisit,Descending)

 

 

 
 
Categories:
  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Sjj9166 ,

    You can change the order to be Ascending, then these Null records will be in the top of gallery.

    If you want to keep order to be Descending, I think the only way is to store the sorted items (Null record at the top) to the new collection, then display it in the gallery.

    You can try to put the following codes to OnSelect of the Sort button, when click it, it will create a new collection that sorts as your expectation 

    ClearCollect(
    myGalleryCollection,
    Filter('[checklist].[HierarchyWithLastVisit]',...,
    DaysSinceLastVisit=Blank()
    )
    );
    Collect(
    myGalleryCollection,
    Sort(
    Filter(
    '[checklist].[HierarchyWithLastVisit]',
    ...,
    DaysSinceLastVisit<>Blank()
    ),
    DaysSinceLastVisit,
    Descending
    )
    );
    Set(Var_Sort,true)

    Also set the following formula to items of gallery, when clicking the button, change Items of gallery to myGalleryCollection.

    If(Var_sort, myGalleryCollection, '[checklist].[HierarchyWithLastVisit]')

    Best regards,

    Sik

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard