Before You Begin
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.
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
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.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.Sentiment.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
Sentiment + COMMENTS into a Table.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.
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
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.
AI_AGG(COMMENTS, 'Summarize the key themes and overall sentiment in 2-3 sentences.', OCCUPATION, OPENAI)
AI_AGG() requires a grouping column (3rd argument). Include OCCUPATION in your visualization to see one summary per group.
Exercise 4 — Assemble the Dashboard
- Canvas 1 — Overview Table:
CUST_ID,COMMENTS,Sentiment,Churn Riskwith conditional formatting. - Canvas 2 — Sentiment Distribution: Bar chart by Sentiment, colored by
OCCUPATION. - Canvas 3 — Risk Analysis: Donut chart of "At Risk" vs "Retained" with filter bar.
- Canvas 4 — Group Summaries: Table with
OCCUPATION+Feedback Summary.
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.
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:
- AI_FILTER() — Sieve through every comment to flag customers showing signs of leaving
- AI_GENERATE() — Classify each comment’s sentiment to understand the “why” behind the churn signal
- AI_AGG() — Roll up insights by occupation or region into executive-ready narrative summaries
The sections below walk through each step with the same data you used in the exercises above.
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.
| CUST_ID | COMMENTS | CHURN 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 |
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_ID | COMMENTS | CHURN RISK | COMPLAINT CATEGORY |
|---|---|---|---|
| 100004 | “...your products are too expensive. Sorry.” | At Risk | Pricing Complaint |
| 100010 | “Unhappy with service. Don’t consider me loyal...” | At Risk | Customer Service |
| 100003 | “I am ready to move on. Not enough variety.” | At Risk | Product 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.
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.
📈 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 BY | AI_AGG PROMPT | AI-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.” |
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
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:
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 DVAOAC 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.
- 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.