Public
Edited
Mar 16, 2023
Fork of ACX Pubs
Insert cell
Insert cell
Insert cell
"034e36f9-7f12-46b5-aee5-4bdd6cb42d26.csv"
Insert cell
// use this for the "other_region" list
import {target_list} from "05afa9b80ca6b800"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Inputs.table(min_max_month)
Insert cell
top_campys = ["BDR", "CLE", "ICT", "SLC", "STL", "CAE", "DSM", "HVN", "SGF"]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof weekly = max_weekly_by_quarter
.groupby('year','week_date')
.rollup({
spend: d => op.sum(d.spend),
leads: d => op.sum(d.leads)
})
.derive({
cpl: d => d.spend / d.leads
})
.view()
Insert cell
viewof weekly_by_campy = max_weekly_by_quarter
.groupby('year','week_date', 'title')
.rollup({
spend: d => op.sum(d.spend),
leads: d => op.sum(d.leads),
bgc: d => op.sum(d.bgc),
activations: d => op.sum(d.activations)
})
// .select('title')
// .dedupe()
// .count()
.view()
Insert cell
viewof clean_max = max_weekly_by_quarter
.groupby('year','quarter', 'month','week', 'title')
.rollup({
spend: d => op.sum(d.spend),
leads: d => op.sum(d.leads)
})
.orderby('year','quarter','week',aq.desc('spend'))
// .select('title')
// .dedupe()
// .count()
.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
spend_range = d3.extent(clean_max, d => d.spend)
Insert cell
lead_range = d3.extent(clean_max, d => d.leads)
Insert cell
Insert cell
Insert cell
viewof file1 = Inputs.file({label: "timeline"})
Insert cell
raw_timeline = file1.xlsx()
Insert cell
timeline = raw_timeline.sheet("SC2 Timeline", {headers: true})
Insert cell
Insert cell
viewof clean = aq.from(raw_data)
.filter(d => d.spend > 0)
// this target list is the download from their csv
.derive({
campaign_category: aq.escape (d => target_list.includes(d.title) == true ? d.title : 'other_region' )
})
.filter(d => d.campaign_category == 'other_region')
.filter(d => d.master_publisher_aggregated == 'Appcast Exchange')
.filter(d => d.title != 'All Other')
.filter(d => d.title != 'Min Bid')
.filter(aq.escape(d => active_campaigns.includes(d.title) == true))
// .select('title')
// .dedupe()
// .count()
.view()
Insert cell
max_weekly_by_quarter
.filter(d => d.year == 2023)
.filter(d => d.week > 7)
.view()
Insert cell
// what is the max weekly yield every quarter by campaign?
// this could potentially give us an idea of seasonality instead of an overall max, median, min view

viewof max_weekly_by_quarter = clean
.derive({
quarter: d => op.utcquarter(d.date) + 1,
week: d => op.utcweek(d.date),
month: aq.escape( d => d3.utcMonth(d.date) ),
week_date: aq.escape(d => d3.utcMonday(d.date)),
year: d => op.utcyear(d.date)
})
.view()
Insert cell
raw_data = file.csv({typed: true})
Insert cell
Insert cell
raw_active_campys = FileAttachment("lyft-by_campaign-2023-03-15-2023-03-15 (1).csv").csv({typed: true})
Insert cell
active_campaigns = aq.from(raw_active_campys)
.filter(d => d.Status == 'Active')
.select('Campaign')
.filter(d => op.includes(d.Campaign, 'Craig') == false)
// .array('Campaign')
.array('Campaign')
Insert cell
Insert cell
Insert cell
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
Insert cell
Insert cell
date_parser = d3.utcParse('%m/%d/%Y')
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