Query editor
WITH setUsers AS(SELECTDISTINCT(user) AS user,date_trunc('month', evt_block_time) as tx_dateFROM dopex_arbitrum.AtlanticStraddle_dpx_evt_PurchaseUNIONSELECTDISTINCT(user) AS user,date_trunc('month', evt_block_time) as tx_dateFROM dopex_arbitrum.AtlanticStraddle_eth_evt_PurchaseUNIONSELECTDISTINCT(user) AS user,date_trunc('month', evt_block_time) as tx_dateFROM dopex_arbitrum.AtlanticStraddle_rdpx_evt_Purchase),base AS(SELECTDISTINCT(tx_date) as month,userFROM setUsersWHERE tx_date >= now() - interval '12' month),user_cohort AS(--get the cohort start month for a specific user addressSELECTMIN(month) AS cohort,userFROM baseGROUP BY 2),cohort_size AS(SELECTcohort,count(*) AS total_sizeFROM user_cohortGROUP BY 1),active_by_cohort AS(SELECTcohort,month,row_number() OVER (partition BY cohort ORDER BY month ASC) AS months,active_addressesFROM(SELECTu.cohort,b.month,count(*) AS active_addressesFROM base bLEFT JOIN user_cohort u ON u.user = b.user