Public
Edited
Mar 10, 2023
Fork of ACX Pubs
Insert cell
Insert cell
Insert cell
file.name
Insert cell
Insert cell
Insert cell
Insert cell
viewof category_lw_spend = aq.from(raw_market_spend_category)
.select('region', 'proposed_budget', 'Spend (2/27 - 3/5)','Change Category')
.view()
Insert cell
lyft_regions = category_lw_spend
.select('region')
.orderby('region')
.array('region')
Insert cell
appcast_regions = clean
.select('region')
.array('region')
Insert cell
raw_market_spend_category = FileAttachment("Appcast Spend Reduction Experiment 2_21 - Data update Mar_6.csv").csv()
Insert cell
viewof clean = aq.from(raw_data)
.rename({'Additional Fields.Geo Code': 'region'})
.derive({
region: aq.escape( d => d.region.toUpperCase() ),
spend: d => +op.replace(d.Actual, ',','')
})
.derive({
region_category: aq.escape( d => lyft_regions.includes(d.region) == true ? d.region : 'other_region' )}, {after: 'region'
})
.view()
Insert cell
Inputs.table(clean)
Insert cell
spend_current_week = clean
.groupby('region_category')
.rollup({
spend_cw: d => op.sum(d.spend)
})
.join(category_lw_spend, ['region_category', 'region'])
// .filter(d => d['Change Category'] == '+0% to +50%' || d['Change Category'] == '+50% to +100%' || d['Change Category'] == '+100% or more')
.derive({
thu_spend_lw: d => ((d['Spend (2/27 - 3/5)']) / 7) * 4
})
.derive({
cw_vs_lw: d => d.spend_cw - d.thu_spend_lw,
cw_vs_budget: d => d.proposed_budget - d.spend_cw
})
//.select(0,1, 'thu_spend_lw', 'cw_vs_lw')
.derive({
'Change Category': d => op.trim(d['Change Category'])
})
.objects()
Insert cell
viewof table = Inputs.table(spend_current_week)
Insert cell
Insert cell
Insert cell
Insert cell
md `## ACX only`
Insert cell
viewof file1 = Inputs.file({label: "Data"})
Insert cell
raw_acx_lw = file1.csv({typed: true})
Insert cell
viewof acx_lw = aq.from(raw_acx_lw)
.rename({'Additional Fields.Geo Code': 'region'})
.derive({
region: aq.escape( d => d.region.toUpperCase() ),
spend: d => +op.replace(d.Actual, ',','')
})
.derive({
region_category: aq.escape( d => lyft_regions.includes(d.region) == true ? d.region : 'other_region' )}, {after: 'region'
})
.groupby('region_category')
.rollup({
spend_lw: d => op.sum(d.spend)
})
.view()
Insert cell
viewof file2 = Inputs.file({label: "Data"})
Insert cell
raw_acx_cw = file2.csv({typed: true})
Insert cell
viewof acx_spend_current_week = aq.from(raw_acx_cw)
.rename({'Additional Fields.Geo Code': 'region'})
.derive({
region: aq.escape( d => d.region.toUpperCase() ),
spend: d => +op.replace(d.Actual, ',','')
})
.derive({
region_category: aq.escape( d => lyft_regions.includes(d.region) == true ? d.region : 'other_region' )}, {after: 'region'
})
.groupby('region_category')
.rollup({
spend_cw: d => op.sum(d.spend)
})
.join(acx_lw)
// .derive({
// thu_spend_lw: d => ((d['Spend (2/27 - 3/5)']) / 7) * 4
// })
.derive({
cw_vs_lw: d => d.spend_cw - d.spend_lw,
//acx_cw_vs_budget: d => d.proposed_budget - d.spend_cw
})
.join(category_lw_spend, ['region_category', 'region'])
.derive({
'Change Category': d => op.trim(d['Change Category'])
})
.derive({
cw_vs_budget: d => d.proposed_budget - d.spend_cw
})
.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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
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