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 Apps
Answered

Default Sort Date

(0) ShareShare
ReportReport
Posted on by 16

Trying to create a default sort (newest to oldest by date) in this Gallery Screen View function selected is 'Items'...any ideas?

It's not wanting to let me add a Sort(SPList, ActivityDate, Ascending, Descending prior to the filter so they will all be filtered). Not sure if I need to add this on each level? Or perhaps I'm trying to get the items wrong.

 

//overall filter allowing users to specify a date range that will reduce the activities returned
Filter(

//if statement to separate admin and user results
If(IsAdmin And !varLoggedInAsUser,

//if user is admin and activity type is "Choose one...", filter by the results entered into the search box
If(
IsBlank(ComboBox1.SearchText) And Dropdown1.SelectedText.Value = "Choose one...",
colSalesActivity,

//user is searched and activity type is "Choose one..."
If(
!IsBlank(ComboBox1.SearchText) And Dropdown1.SelectedText.Value = "Choose one...",
Filter(colSalesActivity, ComboBox1.SearchText in AddedBy.DisplayName),

//user is searched and activity type is NOT "Choose one..."
If(
!IsBlank(ComboBox1.SearchText) And Dropdown1.SelectedText.Value <> "Choose one...",
Filter(colSalesActivity, ComboBox1.SearchText in AddedBy.DisplayName And ActivityType.Value = Dropdown1.SelectedText.Value),

//user is NOT searched and activity type is NOT "Choose one..."
If(
IsBlank(ComboBox1.SearchText) And Dropdown1.SelectedText.Value <> "Choose one...",
Filter(colSalesActivity, ComboBox1.SearchText in AddedBy.DisplayName And ActivityType.Value = Dropdown1.SelectedText.Value))))),

//if user is not admin, they can only see their own records
//check to see if user filters by activity type
If(

//if they don't filter by activity type, the value will be 'Choose one...'
Dropdown1.SelectedText.Value = "Choose one...",
Filter(colSalesActivity, User().Email in AddedBy.Claims),

//if they do select an activity type, filter records by that activity type
Filter(colSalesActivity, ActivityType.Value = Dropdown1.SelectedText.Value And User().Email in AddedBy.Claims))
),

//this line finishes the overall filter that allows date range to be specified
ActivityDate >= DatePicker1.SelectedDate And ActivityDate <= DatePicker1_1.SelectedDate)

Categories:
I have the same question (0)
  • ede21 Profile Picture
    16 on at

    @RandyHayes - Do you by chance have any ideas?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @ede21 

    Reviewing it now....

  • ede21 Profile Picture
    16 on at

    Much appreciated! This is not my formulas, fixing for a colleague so thanks much.

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @ede21 

    Your Items property formula should be the following:

    Sort(
     Filter(colSalesActivity,
     ((IsAdmin && !varLoggedInAsUser) || User().Email in AddedBy.Claims) &&
     (IsBlank(ComboBox1.SearchText) || ComboBox1.SearchText in AddedBy.DisplayName) && 
     ((Dropdown1.Selected.Value = "Choose one...") || ActivityType.Value = Dropdown1.Selected.Value) &&
     ActivityDate >= DatePicker1.SelectedDate &&
     ActivityDate <= DatePicker1_1.SelectedDate
     ),
     ActivityDate,
     Descending
    ) 

     

    You were using SelectedText in your formula - that should be removed as that property is deprecated and should be replaced.  It is replaced above, but the choice of .Value might not be the correct column to reference, so adjust as needed.

     

    I hope this is helpful for you.

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard