Public
Edited
Jan 12, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//Your Inputs here
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
stores
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
daily_products_filtered = {
const fass = daily_products
.filter(product => Categories.includes(product.category))
.filter(product => day_of_week.includes(product.Weekend))
.filter(product => price_range.includes(product.cat_price));

return fass;
}
Insert cell
daily_orders_product
SELECT * FROM
(SELECT
day_of_week,
CASE WHEN day_of_week IN ('Monday','Tuesday','Wednesday','Thursday') THEN 'Weekday' ELSE 'Weekend' END AS Weekend,
name,
CASE
WHEN name like '%Extra Large%' THEN 'Extra Large'
WHEN name like '%Small%' or name like '%Medium%' or name like '%Large%' then SPLIT_PART(name, ' ', -1)
END AS Size,
CASE
WHEN name LIKE '%Extra Large%' THEN REPLACE(name, 'Extra Large', '')
WHEN name LIKE '%Large%' THEN REPLACE(name, 'Large', '')
WHEN name LIKE '%Medium%' THEN REPLACE(name, 'Medium', '')
WHEN name LIKE '%Small%' THEN REPLACE(name, 'Small', '')
END AS Product,
*
FROM
"daily_orders_product") T1
LEFT JOIN
(select
*,
row_number() over (PARTITION BY Size ORDER BY price ASC) AS cat_price
FROM
(SELECT distinct
CASE
WHEN name like '%Extra Large%' THEN 'Extra Large'
WHEN name like '%Small%' or name like '%Medium%' or name like '%Large%' then SPLIT_PART(name, ' ', -1)
END AS Size,
price
FROM
"daily_orders_product"
order by Size,price))T2
ON T1.Size = T2.Size
AND T1.price = T2.price
;
Insert cell
Insert cell
daily_orders
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
import {Treemap} from "@d3/treemap"
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