Skip to main content

Your first TeeBI application

This quickstart guide walks you through creating a simple TeeBI application that imports data from a CSV file, queries it, and displays results in a grid and chart.

What you’ll build

You’ll create an application that:
  • Imports data from a CSV file
  • Performs SQL-like queries on the data
  • Displays results in a grid component
  • Visualizes data with charts
1

Set up your project

Create a new VCL or FireMonkey application in RAD Studio or Lazarus.Add the TeeBI core units to your uses clause:
uses
  BI.DataItem,
  BI.CSV,
  BI.SQL,
  VCLBI.Grid,
  VCLBI.Chart;
For FireMonkey applications, use FMXBI.Grid and FMXBI.Chart instead of the VCL equivalents.
2

Import data from CSV

TeeBI makes importing data extremely simple. Load a CSV file with a single line of code:
var
  Data1: TDataItem;
begin
  // Import data from CSV file
  Data1 := TBICSV.FromFile('mydata.csv');
end;
You can also import from strings or TStrings:
// From a string
Data1 := TBICSV.From('Name,Age,Country' + #13#10 + 'John,25,USA');

// From a memo component
Data1 := TBICSV.From(Memo1.Lines);
TeeBI supports importing from multiple sources:
// From database - loads all tables in one line
Data1 := TBIDB.From(SQLConnection1);

// From JSON
Data1 := TBIJson.From(JsonString);

// From XML
Data1 := TBIXML.From(XmlString);

// From arrays or custom records (via RTTI)
Data1 := TTypeProvider<TCustomer>.Create(Self, MyArrayOfCustomers).Data;

// From components with automatic detection
Data1 := TComponentImporter.From(Self, DataSource1);

// From any URL with automatic format detection
Data1 := TBIURLSource.From('https://www.mysite.com/get/mydata?param=123');

// From AI agents like Google Gemini
Data1 := TBIAI.From('Give me the list of the highest 10 mountains by elevation in csv format');
3

Query your data

Use SQL-like syntax to query and transform your data:
var
  QueryResult: TDataItem;
begin
  // Group by and aggregate
  QueryResult := TBISQL.From(Data1, 
    'sum(Amount) where (Customer=123) and (Product<456) group by Country, Year');

  // Sub-select query
  QueryResult := TBISQL.From(Data1,
    'ProductName, UnitPrice where UnitPrice > select Average(UnitPrice)');

  // Top N with offset (pagination)
  QueryResult := TBISQL.From(Movies,
    'top 100 offset 15000 year, length');
end;
TeeBI queries support:
  • WHERE clauses with complex conditions
  • GROUP BY with multiple fields
  • Aggregate functions: SUM, COUNT, AVG, MIN, MAX
  • HAVING clauses
  • Sub-select queries
  • DISTINCT values
  • TOP N and OFFSET for pagination
  • Date/time operators
  • Expression evaluation
TeeBI queries execute entirely in memory, making them extremely fast even on large datasets.
4

Visualize with grids and charts

Display your data using TeeBI’s built-in visualization components:Using TBIGrid:
// Display data in a grid
BIGrid1.Data := Data1;

// Display a sub-table
BIGrid2.Data := Data1['Products'];
Using TBIChart:
// Display data in a chart
BIChart1.Data := Data1;

// TeeBI automatically selects appropriate chart types
// based on your data structure
TeeBI components automatically visualize complex data structures. The library intelligently chooses appropriate chart types and grid layouts based on your data.
5

Complete example

Here’s a complete working example that combines all the steps:
procedure TForm1.Button1Click(Sender: TObject);
var
  RawData: TDataItem;
  Summary: TDataItem;
begin
  // Step 1: Import data from CSV
  RawData := TBICSV.FromFile('sales.csv');

  // Step 2: Query the data - get sales summary by country
  Summary := TBISQL.From(RawData,
    'sum(Amount) as TotalSales, Country group by Country');

  // Step 3: Display in grid
  BIGrid1.Data := Summary;

  // Step 4: Visualize in chart
  BIChart1.Data := Summary;
end;
This example:
  1. Loads sales data from a CSV file
  2. Creates a summary query that totals sales by country
  3. Displays the results in a grid
  4. Visualizes the data in a chart
All with just a few lines of code!

Working with sub-tables

TeeBI automatically handles relationships between data:
var
  Orders: TDataItem;
  OrderDetails: TDataItem;
begin
  // Import complete database
  Orders := TBIDB.From(SQLConnection1);

  // Access sub-table using array notation
  OrderDetails := Orders['Order Details'];

  // Display sub-table in a grid
  BIGrid1.Data := OrderDetails;
end;
TeeBI creates automatic relationships between columns (master-detail), indexes, and foreign keys.

Exporting data

Export your processed data to various formats:
// Export to CSV
TBICSVExport.Save(Data1, 'output.csv');

// Export to JSON
TBIJsonExport.Save(Data1, 'output.json');

// Export to XML
TBIXMLExport.Save(Data1, 'output.xml');

// Export to Excel, PDF, HTML also supported

Performance tips

TeeBI is designed for speed. Here are some tips to maximize performance:
  • Every column is a simple array - avoid unnecessary copying
  • Queries execute in memory without database overhead
  • Use TDataItem.Capacity to pre-allocate memory for large imports
  • Enable multi-threading for parallel operations when supported
  • Take advantage of indexed searches for faster lookups

Common patterns

Pattern: Import, transform, export

var
  RawData, Cleaned: TDataItem;
begin
  // Import from source
  RawData := TBICSV.FromFile('input.csv');

  // Transform with query
  Cleaned := TBISQL.From(RawData,
    'distinct Name, Email where Email is not null');

  // Export to new format
  TBIJsonExport.Save(Cleaned, 'output.json');
end;

Pattern: Multi-source data integration

var
  FromDB, FromCSV, Combined: TDataItem;
begin
  // Load from different sources
  FromDB := TBIDB.From(SQLConnection1);
  FromCSV := TBICSV.FromFile('additional.csv');

  // Combine and analyze
  Combined := TBISQL.From(FromDB,
    'Customer, sum(Orders) group by Customer');
end;

Pattern: Interactive dashboard

procedure TForm1.ComboBox1Change(Sender: TObject);
var
  Filtered: TDataItem;
  SelectedCountry: string;
begin
  SelectedCountry := ComboBox1.Text;

  // Filter data based on user selection
  Filtered := TBISQL.From(OriginalData,
    'Product, sum(Sales) where Country="' + SelectedCountry + 
    '" group by Product');

  // Update visualizations
  BIGrid1.Data := Filtered;
  BIChart1.Data := Filtered;
end;

Next steps

Now that you’ve created your first TeeBI application, explore these topics:

Core concepts

Deep dive into TDataItem and TeeBI architecture

Importing data

Learn all the ways to import data into TeeBI

Querying data

Master SQL-like queries and data transformations

Visualization

Create stunning charts and grids from your data

Need help?

Build docs developers (and LLMs) love