|
|
Gemini in Google Sheets - AI Data Analysis Agent
Author: Venkata Sudhakar
Google Sheets is where much of Indian business data lives - sales reports, inventory trackers, expense sheets. Connecting Gemini to Sheets enables teams to get instant AI analysis without moving data into a separate tool. The agent reads sheet data, analyses it with Gemini, and writes insights back into a summary tab automatically.
In this tutorial, we build a ShopMax India monthly sales analyser that reads a sales data sheet via the Sheets API, sends the data to Gemini for analysis, and writes a structured insights summary back into a new sheet tab.
The below example shows reading sales data from Google Sheets, analysing with Gemini, and writing the summary back.
Now send the data to Gemini for analysis and write insights back,
It gives the following output,
Read 49 rows from sheet
Analysis complete. Writing back to sheet...
Written 67 cells to AI Insights tab
--- AI Insights Tab Content ---
ShopMax India - AI Sales Analysis - March 2025
Generated by Gemini AI
TOP 3 PRODUCTS BY REVENUE:
- Samsung 55 QLED TV: Rs 18.2 lakhs (23 units)
- Dell Inspiron 15 Laptop: Rs 15.5 lakhs (25 units)
- iPhone 15: Rs 12.8 lakhs (16 units)
BEST PERFORMING REGION:
- Mumbai: Rs 42.3 lakhs (34% of total revenue)
PRODUCT CATEGORY BREAKDOWN:
- Laptops: 38% | TVs: 29% | Mobiles: 21% | Accessories: 12%
RECOMMENDATIONS:
1. Increase TV inventory - sold out in Delhi and Hyderabad
2. Run a laptop promotion in Bangalore - underperforming vs Mumbai
3. Bundle accessories with mobile purchases - low attachment rate
Schedule this script with Cloud Scheduler or a cron job to run automatically at month-end. Add a chart generation step using the Sheets Charts API to visualise the top-products data. For larger datasets, use Gemini with a CSV file upload instead of pasting data into the prompt to stay within context limits.
|
|