Query editor
-- =====================================================================-- 4. UPSHIFT WEEKLY NET FLOW (-> stacked column)-- WoW TVL delta by partner. Preferred over summing action usd_amount,-- which is priced at action time and drifts.---- The series has four missed snapshot Mondays (2026-03-09, 03-16, 04-13, 08-24),-- confirmed as missed job runs rather than a cadence mismatch. LAG() therefore-- compares against the previous PRESENT Monday, so a gap week's delta spans 14 or-- 21 days. days_elapsed exposes that, is_gap_week flags it, and-- net_flow_usd_per_week rescales it to a comparable 7-day rate.-- Chart net_flow_usd_per_week; keep net_flow_usd as the true unscaled delta.-- =====================================================================WITH m AS (SELECTCAST(event_date AS DATE) AS day,partner,SUM(CAST(usd_amount AS DOUBLE)) AS tvl_usdFROM dune.yieldxyz.dataset_upshift_tvlWHERE CAST(is_partner_facing AS VARCHAR) IN ('true', 't', '1', 'TRUE')GROUP BY 1, 2),with_prev AS (SELECTday,partner,tvl_usd,LAG(tvl_usd) OVER (PARTITION BY partner ORDER BY day) AS prev_tvl_usd,LAG(day) OVER (PARTITION BY partner ORDER BY day) AS prev_dayFROM m)SELECTday,partner,ROUND(tvl_usd, 2) AS tvl_usd,ROUND(prev_tvl_usd, 2) AS prev_tvl_usd,date_diff('day', prev_day, day) AS days_elapsed,date_diff('day', prev_day, day) > 7 AS is_gap_week,ROUND(tvl_usd - prev_tvl_usd, 2) AS net_flow_usd,ROUND((tvl_usd - prev_tvl_usd)* 7.0 / date_diff('day', prev_day, day), 2) AS net_flow_usd_per_weekFROM with_prevWHERE prev_tvl_usd IS NOT NULLORDER BY day, net_flow_usd DESC;