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,