You have to use the SharePoint REST API endpoint like this:
https://contoso.sharepoint.com/sites/IDEE/_api/web/lists/GetByTitle('EInfochips')/items?$filter=Department eq 'Admin'
Then in the success function of API call, you can get the count of returned results.
Example 1:
$.ajax({
url: "https://contoso.sharepoint.com/sites/IDEE/_api/web/lists/GetByTitle('EInfochips')/items?$filter=Department eq 'Admin'",
type: "GET",
headers:
{
"Accept": "application/json;odata=verbose"
},
success: function (data, status, xhr) {
var dataresults = data.d.results;
console.log("No. of results: " + dataresults.length);
},
error: function (xhr, status, error) {
console.log("Error");
}
});
Example 2:
let requestUrl = "https://contoso.sharepoint.com/sites/IDEE/_api/web/lists/GetByTitle('EInfochips')/items?$filter=Department eq 'Admin'"
this.context.spHttpClient.get(requestUrl, SPHttpClient.configurations.v1)
.then((response: SPHttpClientResponse) => {
if (response.ok) {
response.json().then((responseJSON) => {
if (responseJSON!=null && responseJSON.value!=null){
let items:any[] = responseJSON.value;
console.log(items.length);
}
});
}
});
Where Department
is the internal name of your choice column. You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?
Check below article to know more about how you can use it in SPFx: How To Work With List Items In SPFx Using REST API - Retrieve List Data
Instead of SPHttpClient and regular SharePoint REST API calls, you can also use SP PnP JS library in SPFx for such requirements.
Example 3:
const allItems: any[] = await sp.web.lists.getByTitle("EInfochips").items.select("Title").filter("Department eq 'Admin'").getAll();
console.log(allItems.length);
Documentation: SP PnP JS - Working with list items