Skip to content

How can I keep a reference to individual items when summarizing in a groupBy? #10

Answered by pbeshai
pbeshai asked this question in Q&A
Discussion options

You must be logged in to vote

This can be accomplished by adding an identity summarizer: items => items, which adds a key with the array of grouped items as its value.

For example:

tidy(
  data,
  groupBy(
    ['group'],
    [summarize({ total: sum('value'), items: (items) => items })]
  )
)

Try it out here on Observable

Replies: 1 comment

Comment options

pbeshai
Feb 5, 2021
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by pbeshai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant