Notes calculates totals for categorized views, but does not sort them.
So if you need it anyway, you have to

  1. navigate the categories in the non-sorted but categorized view (by means of the NotesViewEntry… classes)
  2. create a new document for each category with a field to record that total and a field to record that category
  3. add a non-categorized view for showing the new documents with a sorted column for the total field

Here is the LS code for an agent that implements 1- and 2-

Sub Initialize Dim s As New NotesSession Dim db As NotesDatabase Set db = s.CurrentDatabase Dim v As NotesView Set v = db.GetView( "ViewByCategories" ) ' use here the name of your categorized view Dim n As NotesViewNavigator Set n = v.CreateViewNav Dim e As NotesViewEntry Set e = n.GetFirst ' this should be the first category If e Is Nothing Then Print "empty view... exiting" Exit Sub End If Dim summary As NotesDocument Do While Not( e Is Nothing ) Set summary = new NotesDocument( db ) ' create a new summary document summary.Form = "SummaryForCategory" ' use here the name of your form for the summaries ' set all the fields you need, for example Call summary.ReplaceItemValue( "Total1", e.ColumnValues( 1 ) ) Call summary.Save( True, True ) ' save the summary Set e = n.GetNextCategory( e ) Loop End Sub

(revised text from my own comment 12349447 at Experts-Exchange)