kapa.ai for this JQL, can you change it so it is broken down by quarter, year and not just year?
function main() {
return join(
Events({
from_date: "2020-01-01",
to_date: "2025-12-31",
event_selectors: [{event: "Complete Purchase"}]
}),
People(),
{type: "inner"}
)
.groupBy(
[
// Year of purchase
function(joined) {
return new Date(joined.event.time).getFullYear();
},
// Calculate age using Birthday from user profile with new buckets
mixpanel.numeric_bucket(
function(joined) {
if (!joined.user.properties.Birthday) return -1; // Handle missing Birthday
var birthDate = new Date(joined.user.properties.Birthday);
var purchaseDate = new Date(joined.event.time);
var age = purchaseDate.getFullYear() - birthDate.getFullYear();
// Adjust age if birthday hasn't occurred yet in the purchase year
if (purchaseDate.getMonth() < birthDate.getMonth() ||
(purchaseDate.getMonth() === birthDate.getMonth() &&
purchaseDate.getDate() < birthDate.getDate())) {
age--;
}
return age;
},
[0, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45] // New age buckets as requested
)
],
mixpanel.reducer.count()
);
}