Public
Edited
Jun 7, 2023
Insert cell
Insert cell
Insert cell
file.name
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof by_day_by_campaign = clean
.groupby('date', 'title', 'level')
.rollup({
clicks: d => op.sum(d.clicks),
applies: d => op.sum(d.applies),
spend: d => op.sum(d.spend),
max_cpa_aco_history: d => op.array_agg(d.max_cpa_aco)
})
.derive({
max_cpa: aq.escape(d => d.max_cpa_aco_history.at(-1)),
cpa: d => d.spend / d.applies
})
.derive({
actual_vs_goal_difference: d => d.cpa - d.max_cpa
})
.orderby(aq.desc('actual_vs_goal_difference'))
.filter(d => d.spend > 0 && d.applies > 0)
.view()
Insert cell
Insert cell
viewof clean = aq.from(raw_data)
.filter(aq.escape(d => d.date >= start_date && d.date <= end_date))
.derive({
level: d => op.includes(op.lower(d.title), 'level 1') == true ? 'Level 1' : op.includes(op.lower(d.title), 'level 2') == true ? 'Level 2' : op.includes(op.lower(d.title), 'level 3') == true ? 'Level 3' : 'No level'
})
.view()
Insert cell
raw_data = file.csv({typed: true})
Insert cell
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