Forum Discussion
Power Query OData Top and Filter not working ?
- 1 year ago
Hi Watever,
Thank you for reaching out.
We understand you're trying to get a filtered and limited set of items from your SharePoint list using Power Query, but the $filter, $orderby, and $top options aren't working as expected with OData.Feed. This is a known issue, as Power Query doesn't always apply these options properly due to the way it manages metadata and query folding.
Since your direct web URL works, we suggest using the Web.Contents() function instead. This approach gives you full control over the request and ensures the query parameters are used as intended.
Here’s how you can set up your Power Query with Web.Contents:
let
url = "https://tenant.sharepoint.com/sites/SharepointName/_api/web/Lists/GetByTitle('List_Name')/Items?$filter=Receiving_Site eq 'ABCD'&$orderby=Id desc&$top=2",
Source = Json.Document(Web.Contents(url)),
Items = Source[value]
in
Items
This method should provide the filtered and sorted results you expect. If your dataset is large, make sure your SharePoint list is properly indexed, and check your authentication settings in Excel if you encounter any access issues.
Thank you.
Web.Contents is one approach like v-sgandrathi said!
Supporting articles: not sure whether you got a chance to look into these links:
Hope it helps!