here is an easier way to achieve this, since our names have a stable pattern "flavor Pizza size"
name = "Hawaiian Pizza Large";
get_flavor_easier = name.split(" Pizza ")[0]
get_size_easier = name.split(" Pizza ")[1]
the exact match of the top 5 flavors sold should have been a warning signal to you! when you have something matching exactly like that there must be an error somewhere.
you are not counting units ordered by month, instead you are counting days in a month a pizza was ever ordered: for each size for each state, thus you get a lot of 248 = 31 days x 4 sizes x 2 states for months where there are 31 days and same for other months.
to have that working you need to set reducer to "sum" instead of "count" and then fix one more mistake that looks like a typo
this begs the question — what are the two clusters? you could know by setting the "fill" encoding to different variables, except not quite because you missed one from pizzaorders_new :)
hope you understood/internalised what's going on here
this is a super versatile tool in data wrangling, you find it under other names in different programming languages, but same approach
a d3.flatRollup instead of d3.rollup would simplify the conversion to a regular array because you won't need to flatten it yourself
Grace Chen - Pizza Orders | DV DEVELOP 2025 SPRING Observable Tutorials | Observable