Yes. Why not?
Simple example:
program PivotTable;
{$mode objfpc}
type
TData = record
Category: string;
Value: Integer;
end;
var
Data: array[1..5] of TData;
Summary: array[1..2] of record
Category: string;
Total: Integer;
end;
i, j: Integer;
begin
// Sample data
Data[1].Category := 'A'; Data[1].Value := 10;
Data[2].Category := 'B'; Data[2].Value := 20;
Data[3].Category := 'A'; Data[3].Value := 30;
Data[4].Category := 'B'; Data[4].Value := 40;
Data[5].Category := 'A'; Data[5].Value := 50;
// Initialize summary
Summary[1].Category := 'A'; Summary[1].Total := 0;
Summary[2].Category := 'B'; Summary[2].Total := 0;
// Process data
for i := 1 to Length(Data) do
begin
for j := 1 to Length(Summary) do
begin
if Data[i].Category = Summary[j].Category then
begin
Summary[j].Total := Summary[j].Total + Data[i].Value;
Break;
end;
end;
end;
// Output results
writeln('Category', #9, 'Total');
for i := 1 to Length(Summary) do
begin
writeln(Summary[i].Category, #9, Summary[i].Total);
end;
end.
You probably want something more advanced, which can be done with rtti and generics or sql query.
Principle is the same, though: summarize arbitrary tabular data based on arbitrary fields in a structure.