Get the latest matching SharePoint list item in Power Automate

Suppose a flow needs the most recently edited open request from a SharePoint list. A teammate edited an older open request this morning, then closed a different request five minutes later. Sorting the entire list and grabbing the first row would give you the closed request. Ask SharePoint to filter, sort, and return a single match in one Get items action.

Configure Get items to return one matching record

Create an instant cloud flow with Manually trigger a flow. Add SharePoint’s Get items action and select your site and list. This example uses a single-line text column created with the name Status and the built-in Modified and ID fields. Add these advanced parameters on the action’s Parameters tab.

Get items parameterValueWhat it does
Filter QueryStatus eq 'Open'Keeps only open requests.
Order ByModified desc, ID descPuts the most recently edited item first. If two timestamps match, the higher ID wins.
Top Count1Asks for a single result.

If “latest” means most recently created, change the sort to Created desc, ID desc. An edit to an older request can make it the most recently modified item while its creation date stays the same. SharePoint connector parameters · SharePoint sorting and filtering syntax

Read the title once and handle an empty list

Get items always returns a collection, even with a Top Count of one. Add a Condition immediately after it. In the left value’s expression editor, enter the following. Choose is greater than and enter the number 0 on the right.

length(body('Get_items')?['value'])

In the True branch, add Compose and paste this expression to read the title. For the item ID, replace Title with ID. If you renamed the retrieval action, use its name in both expressions.

first(body('Get_items')?['value'])?['Title']

In the False branch, add a second Compose with the plain text No open requests. Now a quiet day produces an intentional result, and the flow only evaluates first() when a row exists. Using the expression also avoids the Apply to each that the designer may add when you pick a field from the collection. Microsoft’s reference for first()

Try the two cases that catch most mistakes

  1. In a demo list, create two open requests and a closed request. Edit the older open request, then edit the closed request last. Run the flow. The True branch should return the title of the open request you edited.
  2. Close the remaining open requests and run it again. The False branch should show No open requests. If the first run returned an unexpected title, check the spelling of the status value, the sort direction, and whether you intended to sort by Created or Modified.

On a list with more than 5,000 items, Microsoft documents a case where a filtered Get items action can miss a match beyond the first 5,000. Use a selective indexed filter and review the action’s pagination settings before relying on an empty result from a large list. Microsoft’s large-list guidance