With(
{
// Apply filters based on the selected criteria
_Data: Filter(
'Purchase Requisition', // The data source (e.g., SharePoint list)
(
(CheckboxApproved.Checked && Status.Value = "Approved") ||
(CheckboxPending_1.Checked && Status.Value = "Pending") ||
(CheckboxRejected_2.Checked && Status.Value = "Rejected") ||
(!CheckboxApproved.Checked && !CheckboxPending_1.Checked && !CheckboxRejected_2.Checked)
) &&
(IsBlank(varStatusFilter) || Status.Value = varStatusFilter) &&
(IsBlank(DatePickerCanvas1_1.SelectedDate) || 'Date of Requisition' >= DatePickerCanvas1_1.SelectedDate) &&
(IsBlank(DatePickerCanvas2_2.SelectedDate) || 'Date of Requisition' <= DatePickerCanvas2_2.SelectedDate) &&
(IsBlank(txtInput_MinPrice.Value) || Price >= Value(txtInput_MinPrice.Value)) &&
(IsBlank(txtInput_MaxPrice.Value) || Price <= Value(txtInput_MaxPrice.Value)) &&
(
Len(txtInput_Search_2.Value) = 0 ||
txtInput_Search_2.Value in Text(ID) || // Search by ID
txtInput_Search_2.Value in 'Date of Requisition' || // Search by Date of Requisition
txtInput_Search_2.Value in 'Requisitioned by'.DisplayName || // Search by Requisitioned by
txtInput_Search_2.Value in Location.Value || // Search by Location
txtInput_Search_2.Value in Department.Value || // Search by Department
txtInput_Search_2.Value in Status.Value || // Search by Status
txtInput_Search_2.Value in 'Approved by'.DisplayName // Search by Approved by
)
)
},
// Get total number of filtered records after search
With(
{
filteredDataCount: CountRows(_Data)
},
// Apply pagination: display the correct set of records for each page
// Skip records based on the current page (varPage) and display the correct number of records (varRowsPerPage)
FirstN(
LastN(
_Data,
filteredDataCount - ((varPage - 1) * varRowsPerPage) // Skip records for previous pages
),
varRowsPerPage // Limit the number of records per page (e.g., 10 per page)
)
)
)