Query editor
WITH wallets AS (SELECT * FROM "query_8068215"),filtered AS (SELECT * FROM wallets WHERE '{{include_unclassified}}'='include' OR is_product_wallet),bucketed AS (SELECT CASE '{{bucket}}' WHEN 'day' THEN date_trunc('day',effective_unlock_time) WHEN 'week' THEN date_trunc('week',effective_unlock_time) ELSE date_trunc('month',effective_unlock_time) END maturity_bucket,sum(active_xpl) scheduled_xpl_becoming_unlockable,count(*) locking_wallets FROM filtered WHERE effective_unlock_time>=current_timestamp GROUP BY 1) SELECT maturity_bucket,scheduled_xpl_becoming_unlockable,locking_wallets,sum(scheduled_xpl_becoming_unlockable) OVER(ORDER BY maturity_bucket) cumulative_unlockable_xpl FROM bucketed ORDER BY maturity_bucket