2

I am tried to apply Filter on Lookup column using Microsoft graph API filter. But it didn't filter. I have used below api to filter.

https://graph.microsoft.com/v1.0/sites/{sites}/lists/{listname}/items?expand=fields(select=Id,Title,LookUpcolumn)&$filter=Fields/LookUpcolumn eq 'value'.

Any help would be appreciated

Thanks in advance!

4

The the following expression demonstrates how to filter by lookup field id:

&filter=fields/<LookupFieldName>LookupId eq '<LookupFieldValue>'

Pay attention to lookup field name format, in Microsoft Graph lookup field value is exposed for Lookup Id by default

Example

Lets assume Employee list contains Department lookup field (refers to Department list), then the following query:

https://graph.microsoft.com/v1.0/sites/root/lists/Employee/items?expand=fields(select=Id,Title,Department)&filter=fields/DepartmentLookupId eq '<deplookupId>'

will return list items filtered by Department lookup Id value

Update

It seems Graph API does not support to apply filter by lookup value

As a workaround you could consider the following solution to filter by lookup value (requires two requests).

Given the above example

1)first step would be to query Departments list by Title and return Id property (which corresponds to DepartmentLookupId property in Employee list):

https://graph.microsoft.com/v1.0/sites/root/lists/Department/items?expand=fields(select=Id)&filter=fields/Title eq '<value>'

2) and then to query Employee list by Department lookup Id:

https://graph.microsoft.com/v1.0/sites/root/lists/Employee/items?expand=fields(select=Id,Title,Department)&filter=fields/DepartmentLookupId eq '<deplookupId>'
  • 1
    Thanks Vadim, You were right. But I want to filter with Text not a ID. – Bharat Khunti Apr 7 '18 at 20:22
  • Bharat, indeed, the provided solution demonstrated how to filter by lookup id. The answer has been updated. – Vadim Gremyachev Apr 8 '18 at 11:19
  • 2
    Don't forget to index the column you plan to use in filter. – Falak Mahmood Jul 12 '18 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.