Public
Edited
Aug 29, 2023
Fork of Template
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
vl.markRect({tooltip: true})
.data(clean)
.encode(
vl.x().fieldT('week')
.timeUnit('utcweek')
.axis({orient: 'top'}),
vl.y().fieldN('Campaign')
.sort(vl.median('cpl').order('descending')),
vl.color().fieldQ('cpl')
)
.config({
view: {stroke: null},
axis: {grid: null, domain: null}
})
.render()
Insert cell
Insert cell
leads_change_wow = Inputs.table(leads)
Insert cell
leads
.derive({
change: d => d.week_diff > 0 ? 'increase' : 'decrease'
})
.groupby('change')
.count()
.view()
Insert cell
viewof cpl = clean
.filter(d => d.week > op.utcdatetime(2023,7,13))
.derive({
week_segment: d => d.week >= op.utcdatetime(2023, 7, 21) ? 'week2' : 'week1'
})
.groupby('Campaign')
.pivot('week_segment', 'cpl')
.derive({
week_diff: d => d.week2 - d.week1
})
.derive({
change: d => d.week_diff > 0 ? 'increase' : 'decrease'
})
.orderby(aq.desc('week_diff'))
.view()
Insert cell
cpl_change_wow = Inputs.table(cpl)
Insert cell
cpl
.derive({
change: d => d.week_diff > 0 ? 'increase' : 'decrease'
})
.groupby('change')
.count()
.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof clean = aq.from(raw_lyft)
.join(aq.from(raw_list), ['title', 'Campaign'])
.filter(d => d['Campaign group'] == 'Back To School')
.derive({
week: aq.escape(d => d3.utcMonday(d.date))
})
.groupby('week', 'Campaign')
.rollup({
spend: d => op.sum(d.spend),
leads: d => op.sum(d.leads)
})
.derive({
cpl: d => d.spend / d.leads
})
.view()
Insert cell
raw_lyft = file.csv({typed: true})
Insert cell
Insert cell
raw_list = FileAttachment("lyft-by_campaign-2023-08-28-2023-08-29.csv").csv({typed: true})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// this is a really cool way of displaying tables. Much more aesthetically pleasing than the defaults of arquero and input.table

import { formatTable } from "@saneef/pretty-tables"
Insert cell
Insert cell
import {toc} from "@nebrius/indented-toc"
Insert cell
Insert cell
date_parser = d3.utcParse('%m/%d/%Y')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// sample of how to place html blocks in a grid

// html `<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; column-gap: 0px; row-gap: 5px;">
// ${viewof spend}
// ${viewof cpl}
// ${viewof cpc}
// </div>`
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more