Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Is there a way to get a count of a subset of the results #378

Open
bryllyg opened this issue Mar 22, 2021 · 2 comments
Open

[Question] Is there a way to get a count of a subset of the results #378

bryllyg opened this issue Mar 22, 2021 · 2 comments

Comments

@bryllyg
Copy link

bryllyg commented Mar 22, 2021

Hi,

I still learning what I can and can't do in handlebars. I'm trying to figure out if I can get a count of a subset (filtered by field value) of the search query. For example, if I search for 'Engagements' and it returns 120 items, I would like to then be able to show that within those 120 items 23 are 'Active'. I've read through the handlebars info and tinkered, but I'm not sure this is doable with the helpers provided. Am I missing something? Thanks for any advice!

H

@Devilthehell
Copy link

Hey @bryllyg,

I think you might be able to get a count on how many are active by plucking the data, stringifying the array and then counting the occurrences of "Active"

{{occurrences (stringify (pluck Engagements "Status")) "Active"}}

Please bear with me, if my response is not proper, I am new to Github.
Any recommendations on a better response format would be appreciated.

@bryllyg
Copy link
Author

bryllyg commented Jun 30, 2021

Hi @Devilthehell, Thanks! That's very helpful. I don't currently have access to pluck (it's not in the build of PnP Search I'm working with) but I'll get in a request for it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants