<link rel="stylesheet" href="https://53.fs1.hubspotusercontent-na1.net/hubfs/53/hub_generated/template_assets/1/207928094053/1783957703545/template_footer-core-non-critical.min.css">

Build an AI Data Analysis Agent in Codex

A step-by-step framework for using Codex as an AI data analyst — from raw dataset to root-cause finding to leadership-ready deck in 30 minutes.

Create, optimize, and measure content that actually drives leads with Content Hub.

Your VP wants to know why retention dropped last week. It's Friday at noon. You have two hours and a CSV file.

In the past, that meant pivot tables, gut feel, and a hypothesis you weren't confident in. Today, it means opening Codex, directing an AI data analyst with one well-structured prompt, and walking into that meeting with a root-cause analysis, a validated finding, and a deck you built in under 30 minutes.

This guide shows you how to do exactly that — step by step.

Before You Start

1. Pick your tool — use your company's approved version.

Codex is the recommended tool for this workflow but if you or your company uses a different tool, the prompt framework works well with these options:

 

Regardless of which tool you use: if your company has an enterprise subscription, use that. Do not upload business data into a personal free-tier account.

2. Have a specific problem, not a vague one.
"What's wrong with my data?" produces nothing. "Why did our MQL-to-SQL conversion rate drop from 34% to 21% between Q1 and Q2?" produces a root-cause analysis. The more specific the question, the sharper the output.

3. Bring more data than you think you need.
If a segment only has 12 records, the AI will find patterns in it — and those patterns will be meaningless. More rows, better analysis.

~10 minutes

Step 1: Clean your data export

  1. Rename columns to plain English. opp_stg_v2Opportunity Stage. cam_srcCampaign Source. The AI reads column headers as instructions. Make them legible.
  2. Delete columns irrelevant to your question. Analyzing MQL-to-SQL conversion? You don't need the billing address field. A focused dataset produces a focused analysis.
  3. Standardize your date formats. Mixed formats across rows will cause the AI to misread time-series patterns. Pick one format, apply it to every date column.
  4. Remove obvious junk rows. Test leads, internal email domains, records missing the key metric you're analyzing. Don't sanitize the whole dataset — just cut the noise that would distort a trend.
💡 Pro Tip: Check for missing values before you run anything. If your data has gaps in key columns, the AI will work around them silently and give you conclusions based on incomplete information. Ask it upfront: "Are there any missing values or data quality issues in this file I should know about before we start?"

 

~5 minutes

Step 2: Write a root-cause prompt

The wrong prompt sounds like, "What insights can you find in this data?"

A prompt that’s too open-ended invites generic output. What you get back is a summary of what's in the dataset — not an explanation of why something happened.

A root-cause prompt does three things: gives the AI business context it doesn't have, specifies the outcome you're trying to explain, and asks it to reason about causation — not just flag correlations.

~5 minutes

Step 3: Read the first output like a skeptic

Upload your cleaned CSV, paste your prompt, hit send. Here's how to read the output efficiently:

  • Read conclusions first, reasoning second. If a finding immediately contradicts something you already know, that's important signal — note it, don't ignore it.
  • Pay attention to what it didn't find. No difference across lead source channels? That tells you the problem is probably not channel-specific — which narrows your investigation considerably.
  • Take confidence qualifiers seriously. "This correlation is weak" or "the sample size for this segment is small" means that finding needs human verification before you act on it.
  • Don't treat the first output as the final answer. It's the start of the analysis. The next step is where the real value comes from.

~5 minutes

Step 4: Push back with follow-up prompts

 Use these follow-up prompts to pressure-test the findings.

~5 minutes

Step 5: Validate before you act

Run these three checks before treating any finding as confirmed.

~2 minutes

Step 6: Turn your findings into a deck

Once you have a validated finding, you don't need to manually build a presentation. Ask Codex or Claude Code to do it directly from the analysis output.

After 30 minutes, you'll have one of three things

  • A confirmed finding — enough evidence to brief your team or change a decision. Write it up in one paragraph: what changed, what's driving it, what you're doing about it.
  • A strong hypothesis — plausible and supported by the data, but not fully validated. Identify the one piece of evidence that would confirm or kill it. Go get it.
  • A data gap — you've learned your current data isn't sufficient to answer the question. That's still a valuable outcome. Now you know exactly what to instrument or ask RevOps to pull.