Query editor
WITH raw AS (SELECTdate AS block_date,daily_l1_transactions AS raw_tx,CAST(AVG(CAST(daily_l1_transactions AS DOUBLE)) OVER (ORDER BY date ROWS BETWEEN 7 PRECEDING AND 1 PRECEDING) AS BIGINT) AS trailing_avgFROM dune.w3io.protocol_onchain_activity),smoothed AS (SELECTblock_date,CASEWHEN trailing_avg > 0 AND raw_tx > trailing_avg * 1.5THEN CAST(trailing_avg * 1.5 AS BIGINT)ELSE raw_txEND AS transactionsFROM raw)SELECTblock_date,transactions,SUM(transactions) OVER (ORDER BY block_date) AS cumulative_transactions,CAST(AVG(CAST(transactions AS DOUBLE)) OVER (ORDER BY block_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS BIGINT) AS ma_7dayFROM smoothedORDER BY block_date