Oracle Analytics
Step 2 · Hands-On Exercise

Build It Yourself: Step-by-Step Walkthrough

A guided hands-on exercise to build a complete AI-powered customer insights workbook using AI_GENERATE(), AI_AGG(), and AI_FILTER() against real data in Oracle Analytics Cloud.

R
Ravi Shanker B · Principal Solutions Architect · March 2026

Before You Begin

Prerequisites

Complete the Setup Guide first. You need: an OAC instance with a registered AI model, access to the SH schema (SUPPLEMENTARY_DEMOGRAPHICS table), and a working Select AI profile.

Cost Awareness

Row-level functions (AI_GENERATE, AI_FILTER) make one LLM call per row. Filter your data to limit row count during development.

Exercise 1 — Classify Sentiment with AI_GENERATE()

Create a calculated column that classifies customer comments into sentiment categories.

Step-by-Step

1
Create a Dataset
From the OAC Home page, click CreateDataset. Select your database connection that has the SH (Sales History) schema. Navigate to the SH schema and add all the related tables — SALES, CUSTOMERS, PRODUCTS, CHANNELS, TIMES, COUNTRIES, and SUPPLEMENTARY_DEMOGRAPHICS. OAC will auto-detect the joins between them. Save the dataset with a name like SH_Sales_Demo. For this exercise, the key column is COMMENTS in the SUPPLEMENTARY_DEMOGRAPHICS table — this is the free-text column containing customer feedback that we’ll use across all three AI functions.
2
Create a Workbook from the Dataset
From the OAC Home page, click CreateWorkbook. In the Add Data dialog, search for and select the dataset you just created (SH_Sales_Demo). Click Add to Workbook. You should see columns like CUST_ID, COMMENTS, OCCUPATION, EDUCATION, etc. in the Data Panel on the left.
3
Add Calculation
In the Data Panel, right-click My CalculationsAdd Calculation. Name it: Sentiment.
4
Enter Expression
Paste the expression below:
OAC ExpressionSentiment
CASE WHEN COMMENTS IS NULL OR LENGTH(TRIM(COMMENTS)) = 0
THEN 'No Comment'
ELSE AI_GENERATE(COMMENTS,
  'Classify this feedback as Positive, Negative, Mixed, or Neutral. Return only the label.',
  OPENAI)
END
5
Validate & Visualize
Click Validate, then drag Sentiment + COMMENTS into a Table.
Expected Output

Each row shows a sentiment label. Empty comments → "No Comment".

Exercise 2 — Flag Churn Risk with AI_FILTER()

Identify customers at risk of leaving based on comment analysis.

OAC ExpressionChurn Risk
CASE WHEN COMMENTS IS NULL OR LENGTH(TRIM(COMMENTS)) = 0
THEN 'No Comment'
WHEN AI_FILTER(
  'Does this comment suggest the customer may stop purchasing or is at risk of leaving?',
  COMMENTS, OPENAI)
THEN 'At Risk'
ELSE 'Retained'
END

Optional: Price Complaint Filter

OAC ExpressionPrice Complaint
CASE WHEN COMMENTS IS NULL OR LENGTH(TRIM(COMMENTS)) = 0
THEN 'No Comment'
WHEN AI_FILTER('Is the customer complaining about price or cost being too high?',
  COMMENTS, OPENAI)
THEN 'Price Complaint'  ELSE 'OK'
END

Exercise 3 — Summarize by Group with AI_AGG()

AI_AGG() generates one narrative summary per group — ideal for occupation-level or region-level insights.

OAC ExpressionFeedback Summary
AI_AGG(COMMENTS,
  'Summarize the key themes and overall sentiment in 2-3 sentences.',
  OCCUPATION, OPENAI)
Group Attribute Required

AI_AGG() requires a grouping column (3rd argument). Include OCCUPATION in your visualization to see one summary per group.

Exercise 4 — Assemble the Dashboard

  1. Canvas 1 — Overview Table: CUST_ID, COMMENTS, Sentiment, Churn Risk with conditional formatting.
  2. Canvas 2 — Sentiment Distribution: Bar chart by Sentiment, colored by OCCUPATION.
  3. Canvas 3 — Risk Analysis: Donut chart of "At Risk" vs "Retained" with filter bar.
  4. Canvas 4 — Group Summaries: Table with OCCUPATION + Feedback Summary.
Pro Tip

Use Canvas tabs and Dashboard Filters for interactive slicing.

Real-World Scenario — Solving Customer Churn with AI Functions

Now that you’ve built the core calculations, let’s put them to work on a real business problem.

The Use Case

Your company collects thousands of customer feedback comments every quarter — but no one reads them. Leadership suspects customers are churning, but the COMMENTS column sits untouched in the data warehouse because traditional BI tools can’t process free text.

Your goal: Use the three AI functions you just learned to turn that raw feedback into a churn intelligence dashboard — identifying who’s at risk, understanding why, and summarizing the patterns for executive review.

Here’s how we solve it, one function at a time:

The sections below walk through each step with the same data you used in the exercises above.

The 3-Step AI Workflow
🔎
Step 1: Find
AI_FILTER()
The Smart Sieve finds at-risk customers
🏷
Step 2: Understand
AI_GENERATE()
The Label Maker explains the ‘why’
📊
Step 3: Summarize
AI_AGG()
The Super-Summarizer sees the big picture
1
Find At-Risk Customers
AI_FILTER() — The Smart Sieve

The first question any customer success team asks: “Which customers are about to leave?”

With AI_FILTER(), you write that question — in plain English — directly in the OAC expression editor. The AI reads every single comment and, wrapped in a simple CASE WHEN expression, returns a meaningful label for each customer: “At Risk” or “Retained”.

No regex patterns. No keyword lists that miss subtle signals. The AI understands context, sarcasm, and indirect language that rule-based filters would never catch.

⚡ The result? Instant clarity.

In seconds, thousands of comments are classified. You now have a structured column you can filter, chart, and act on.

AI_FILTER data table from Churn Briefing video
🎬 AI_FILTER results — at-risk customers identified from free-text comments
CUST_IDCOMMENTSCHURN RISK
100851“Thank you, But please remove my name from your list.”At Risk
100893“I used to shop at your store, but have stopped now. I tried to return items and your store manager was a pain.”At Risk
100946“Thank you, But please remove my name from your list.”At Risk
100826“I love shopping with my Affinity Card! I purchased a new flat panel monitor. Amazing!”Retained
🔍
Notice something? The comment “please remove my name from your list” doesn’t contain the word “churn”, “cancel”, or “leave”. A keyword-based filter would miss it entirely. The AI understands the intent, not just the words.
2
Pinpoint the Problem
AI_GENERATE() — The Label Maker

Knowing who is at risk is only half the battle. The next question is: “Why are they at risk?”

AI_GENERATE() reads each at-risk comment and generates a complaint category — a new column of AI-created labels that tells you exactly what went wrong. Is it pricing? Customer service? Product variety? Shipping?

In one expression, you go from a wall of unstructured text to an actionable breakdown of root causes.

CUST_IDCOMMENTSCHURN RISKCOMPLAINT CATEGORY
100004“...your products are too expensive. Sorry.”At RiskPricing Complaint
100010“Unhappy with service. Don’t consider me loyal...”At RiskCustomer Service
100003“I am ready to move on. Not enough variety.”At RiskProduct Variety

🎯 From “customers are leaving” to “here’s why”

Now you don’t just know the who — you know the why. That’s the difference between a reactive response and a strategic intervention. Product team can fix variety. Pricing team can review margins. Support can retrain staff. Each team gets an actionable signal, not a vague alert.

3
See the Big Picture
AI_AGG() — The Super-Summarizer

You now know who is at risk (AI_FILTER) and why (AI_GENERATE). But your leadership team doesn’t want to scroll through 800 individual comments. They need the big picture: “What are the systemic themes driving churn across our entire customer base?”

This is where AI_AGG() shines. It groups all comments by a dimension you choose — region, product line, customer segment, time period — and feeds the entire group to the LLM in a single call. The result? One concise, AI-generated executive summary per group.

AI_AGG results from Churn Briefing video
🎬 AI_AGG regional summaries — systemic themes emerging from grouped analysis

📈 What AI_AGG unlocks that the other two can’t

AI_FILTER and AI_GENERATE work row by row. AI_AGG works across rows. It spots patterns that only emerge when you look at many comments together — recurring themes, correlated complaints, and systemic issues that no single row would reveal.

GROUP BYAI_AGG PROMPTAI-GENERATED SUMMARY
West Region“Summarize the main complaints from these at-risk customers”“Customers consistently cite pricing as the primary concern, with several referencing competitor promotions. A secondary theme is dissatisfaction with in-store return policies.”
East Region“Summarize the main complaints from these at-risk customers”“The dominant theme is poor customer service, particularly around a specific store location. Multiple customers mention unhelpful staff and long wait times.”
Online Channel“Summarize the main complaints from these at-risk customers”“Shipping delays and limited product variety are the top issues. Several customers mention switching to competitors with faster delivery.”
💡
The analytical power here is enormous: Instead of asking “What do these 250 West Region complaints say?” and reading each one, AI_AGG distills them into a single actionable paragraph. The VP of Operations gets a one-line answer. The regional manager gets a clear mandate. And it took seconds, not days of manual review.
📊
New analytical angles AI_AGG opens up:
By Region — Detect which geographies have systemic service problems
By Product Line — Surface which products generate the most frustration and why
By Quarter — Track how complaint themes shift over time (are pricing concerns growing?)
By Customer Tier — Understand if high-value customers leave for different reasons than others
💼
Executive Briefing: Top 3 Systemic Themes
The actionable intelligence that emerges when all three AI functions work together

When you combine AI_FILTER (who), AI_GENERATE (why), and AI_AGG (big picture), a clear executive-level story emerges. Here are the top three systemic themes driving churn across the customer base:

Top 3 Systemic Themes from Churn Briefing video
🎬 Executive Briefing: Top 3 Systemic Themes driving customer churn
📈 Theme 1: Pricing
Competitor promotions are driving churn in the West.
Customers consistently cite pricing as the primary concern, with several referencing competitor offers they find more attractive.
👥 Theme 2: Service
Poor in-store service is the dominant issue in the East.
The dominant theme centers on negative customer service interactions, particularly around specific store locations and managers.
🚚 Theme 3: Logistics
Shipping delays & product variety hurt the Online Channel.
Online customers report frustration with delivery times and limited product selection, with several mentioning switching to competitors.
💡
From the “AI Analyst: Churn Briefing” video: These three themes didn’t come from weeks of manual analysis. They emerged in minutes — AI_FILTER identified the at-risk customers, AI_GENERATE categorized the complaints, and AI_AGG summarized the systemic patterns by region. Each team now has a clear, actionable mandate: Pricing team reviews competitor benchmarks. Operations addresses in-store service. Logistics tackles shipping SLAs.

Compare Your Work — Sample Reference DVA

Download the sample reference .dva file below to compare your workbook against a pre-built version with all three AI functions configured.

📦

OAC_AI_Functions.dva

Sample reference workbook with AI_GENERATE, AI_FILTER, and AI_AGG expressions pre-configured

⬇ Download Sample DVA
How to Import

OAC Home → Import Workbook/Flow → select the downloaded .dva file, or simply drag it into the browser. After import, re-map the data connection to point to your own database with the SH schema.

What to Compare
  • Sentiment labels generally align (exact match not expected — LLMs are non-deterministic)
  • Churn Risk flags the same general at-risk customers
  • AI_AGG summaries capture similar themes


The opinions and views shared here are solely those of the author and do not represent the official stance or policy of Oracle Corporation.