Query editor
WITH-- Step 1: Filter the historical data based on the chains selected in the parameter.filtered_data AS (SELECTmonth_start,blockchain,yellow_belt_wallet_count,total_usd_valueFROMdune.web3cryptotech.dataset_yellow_belt_historical_data_base_ethWHERECASEWHEN '{{chain}}' = 'all' THEN TRUE -- If 'all' is selected, include all blockchainsELSE blockchain IN (SELECT TRIM(value) FROM UNNEST(SPLIT('{{chain}}', ',')) AS t(value))END)-- Step 2: Select the data for each individual chain.SELECTmonth_start,blockchain,yellow_belt_wallet_count,total_usd_valueFROMfiltered_dataUNION ALL-- Step 3: Calculate the aggregated "EVM-wide" totals for the selected chains.-- This creates a separate series on the graphs.SELECTmonth_start,'EVM-wide' AS blockchain, -- Assign a specific name for the aggregated seriesSUM(yellow_belt_wallet_count) AS yellow_belt_wallet_count,SUM(total_usd_value) AS total_usd_valueFROMfiltered_dataGROUP BY1 -- Group by month_startORDER BYmonth_start,blockchain;