Back to Snowflake Basic in Google Sheets
SheetXAI logo
Snowflake Basic logo
Snowflake Basic · Google Sheets Guide

Run an Analytical SQL Query in Snowflake and Write Results Into a Google Sheet

2026-05-14
5 min read

The Scenario

It's 4:30 PM on a Tuesday and you've been asked to update the leadership dashboard before tomorrow's 9 AM all-hands. The dashboard lives in a Google Sheet. The data — 12 months of monthly active user counts — lives in Snowflake.

You know the table. You've pulled this data before. The bad version goes like this:

The bad version:

  • Open the Snowflake UI, navigate to the right worksheet, paste the SQL, wait for the 40-second query, and export the results as a CSV.
  • Import the CSV into the sheet, fix the date column that came in as text, delete the query metadata row Snowflake prepended, and match the headers to what the dashboard expects.
  • Discover that the date format is wrong for the chart axis, reformat the column, and manually reconcile the row count against the previous version to make sure nothing dropped.

You're supposed to be doing analysis, not pipeline work. The dashboard needs to go out tonight, and this manual sequence is not a fast one.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Google Sheet. It reads your spreadsheet, understands what you're working with, and through its built-in Snowflake connection it can run SQL and write results directly into the sheet for you.

Open the SheetXAI sidebar and paste this prompt:

Run this SQL in Snowflake database PROD schema ANALYTICS: SELECT DATE_TRUNC('month', event_date) AS month, COUNT(DISTINCT user_id) AS mau FROM events WHERE event_date >= DATEADD(month, -12, CURRENT_DATE()) GROUP BY 1 ORDER BY 1 — write the results into the Dashboard tab starting at A1 with headers

What You Get

  • Row 1 populated with headers: month and mau
  • Rows 2–13 populated with the 12 monthly records, one per row
  • Dates formatted as YYYY-MM-01, readable by the sheet's chart axis without reformatting
  • If the query returns an error from Snowflake, the error message lands in A1 so you see it immediately

What If the Data Is Not Quite Ready

The date column is arriving as a Unix timestamp instead of a readable date

Run the same MAU query in Snowflake database PROD schema ANALYTICS, but cast the DATE_TRUNC result as DATE before returning it — write the output into the Dashboard tab starting at A1 with headers, and format column A as YYYY-MM

The query needs to exclude internal test users

Run this SQL in Snowflake PROD.ANALYTICS: SELECT DATE_TRUNC('month', event_date) AS month, COUNT(DISTINCT user_id) AS mau FROM events WHERE event_date >= DATEADD(month, -12, CURRENT_DATE()) AND user_id NOT IN (SELECT user_id FROM users WHERE is_internal = TRUE) GROUP BY 1 ORDER BY 1 — write results into Dashboard tab at A1 with headers

The MAU numbers need to be joined with seat counts from a second table

Run a query in Snowflake PROD.ANALYTICS that joins the events table to the accounts table on account_id to get monthly active users and monthly active accounts side by side for the last 12 months — write month, mau, and maa into columns A, B, and C of the Dashboard tab starting at A1

The MAU query needs to clean data, flag anomalies, and write the results in one shot

Run the MAU query in Snowflake PROD.ANALYTICS for the last 12 months, flag any month where MAU dropped more than 15% from the prior month with 'DROP' in column C, and write month, mau, and flag into columns A–C of the Dashboard tab — if a month has no data write 'MISSING' in column B

The underlying principle: ask for the filter, the join, the cleanup, and the write in a single prompt rather than assembling the steps separately.

Try It

Get the 7-day free trial of SheetXAI and open the Google Sheet where your leadership dashboard lives, then ask it to pull fresh MAU data from Snowflake directly into the dashboard range. You can also explore listing Snowflake databases and schemas or return to the Snowflake overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more