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

Count distinct values in group operation #412

Closed
kristian-kyvik opened this issue May 20, 2021 · 2 comments · Fixed by #427
Closed

Count distinct values in group operation #412

kristian-kyvik opened this issue May 20, 2021 · 2 comments · Fixed by #427
Assignees
Labels
enhancement New feature or request

Comments

@kristian-kyvik
Copy link

Hi,
I was wondering if there was any way I could group and count distinct values. Something I could achieve using the following in vega-lite:
vl.y().distinct

@Fil Fil added the enhancement New feature or request label May 20, 2021
@Fil
Copy link
Contributor

Fil commented May 21, 2021

You can create your own reducer, for example in https://observablehq.com/@fil/plot-count-distinct we read species in "y" and count the number of distinct values with (series) => new Set(series).length.

It could be nice to have a shorthand reducer for this, maybe { y: "distinct" }.

@Fil
Copy link
Contributor

Fil commented May 29, 2021

see also #420

@Fil Fil self-assigned this May 29, 2021
Fil added a commit that referenced this issue Jun 3, 2021
@Fil Fil closed this as completed in #427 Jul 10, 2021
Fil added a commit that referenced this issue Jul 10, 2021
* group reduce: "distinct"

closes #412

* missing test

* document "distinct" reduce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants