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 / Filter of search galle...
Power Apps
Answered

Filter of search gallery by fieldname and start- and enddate

(0) ShareShare
ReportReport
Posted on by 242

Hi,

I would like to sort a gallery by the field StartDatum en Approval state Pending.
These Items have to be shown first.

And I have a searchbox for the gallery. T
It has to be possible to search for the field called Aanvrager.
And it would be perfect if it were posible to also filter on StartDate and EndDate.

How can i achieve this?
@v-xida-msft 

Categories:
I have the same question (0)
  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Mirtemir ,

    Do you want to filter your Gallery Items based on a TextSearchBox?

    Do you also want to sort your Filtered result based on StartDatum column?

    Further, could you please share a bit more about the “Approval state” column? Is it a Choice type column?

     

    Firstly, if you want to filter your Gallery Items based on a TextSearchBox, please consider set the Items property of the Gallery to following:

    Filter(
     ExpenseMaster;
     Aanvrager.DisplayName in 'Office365-gebruikers'.DirectReportsV2(
     'Office365-gebruikers'.ManagerV2('Office365-gebruikers'.MyProfileV2().id).id
     ).value.displayName,
     SearchTextBox.Text in Aanvrager.DisplayName
    )

     

    If you want to sort above Filtered result by the StartDatum column, please try the following formula:

    Sort(
     Filter(
     ExpenseMaster;
     Aanvrager.DisplayName in 'Office365-gebruikers'.DirectReportsV2(
     'Office365-gebruikers'.ManagerV2('Office365-gebruikers'.MyProfileV2().id).id
     ).value.displayName;
     SearchTextBox.Text in Aanvrager.DisplayName
     );
     StartDatum;
     Descending
    )

     

    For filtering result based on the StartDate and EndDate, you could add two DatePicker controls in your app, rename them as "StartDatePicker" and "EndDatePicker". Then remove the formula from the DefaultDate property of the two DatePicker controls. Then, modify your formula as below:

    Sort(
     Filter(
     ExpenseMaster;
     Aanvrager.DisplayName in 'Office365-gebruikers'.DirectReportsV2(
     'Office365-gebruikers'.ManagerV2('Office365-gebruikers'.MyProfileV2().id).id
     ).value.displayName;
     SearchTextBox.Text in Aanvrager.DisplayName;
     If(
     !IsBlank(StartDatePicker.SelectedDate);
     StartDate = StartDatePicker.SelectedDate;
     true
     ),
     If(
     !IsBlank(EndDatePicker.SelectedDate);
     EndDate = StartDatePicker.SelectedDate;
     true
     )
     );
     StartDatum;
     Descending
    )

     

    If the “Approval state” column is a Choice type column, and you want these records whose “Approval state” column value is Pending to be shown up first in your Gallery, I afraid that there is no direct way to achieve your needs. As an alternative solution, please check the following workaround:

    Set the OnStart property of App to following:

    ClearCollect(
     RecordsCollection;
     Filter(ExpenseMaster; 'Approval state'.Value = "Pending");
     Filter(ExpenseMaster; 'Approval state'.Value <> "Pending")
    )

    Then set the Items property of the Gallery to following:

    Sort(
     Filter(
     RecordsCollection; // replace here with collection table
     Aanvrager.DisplayName in 'Office365-gebruikers'.DirectReportsV2(
     'Office365-gebruikers'.ManagerV2('Office365-gebruikers'.MyProfileV2().id).id
     ).value.displayName;
     SearchTextBox.Text in Aanvrager.DisplayName;
     If(
     !IsBlank(StartDatePicker.SelectedDate);
     StartDate = StartDatePicker.SelectedDate;
     true
     ),
     If(
     !IsBlank(EndDatePicker.SelectedDate);
     EndDate = StartDatePicker.SelectedDate;
     true
     )
     );
     StartDatum;
     Descending
    )

    Please re-load your canvas app (fire the OnStart property of App), then check if the above solution is helpful.

     

    Best regards,

  • Mirtemir Profile Picture
    242 on at

    Thanks, the code works:

    Sort( Filter( ExpenseMaster; Aanvrager.DisplayName in 'Office365-gebruikers'.DirectReportsV2( 'Office365-gebruikers'.ManagerV2('Office365-gebruikers'.MyProfileV2().id).id ).value.displayName; SearchTextBox.Text in Aanvrager.DisplayName ); StartDatum; Descending )

     

    I will try the datepicker also but even this is sufficient for now.

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
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard