Hi there, I have a custom column which essentially does what you're asking - it's True if the book is either standalone or first in series (even if the series index doesn't begin at 1) and False otherwise. I find it useful to have this info in a column (called #first_in_series) so I can search very easily (either #first_in_series:=True or False). Here are the steps:
1. Preferences - Advanced - Tweaks - set "allow_template_database_functions_in_composit es = True"
2. Add column - column built from other columns (see attached pic)
3. Copy this code into the column template:
Code:
program:
# Returns True if it is the first book in a series (or a standalone book with no series), including cases where the series index does not begin at 1.
# Returns False otherwise
first_in_series = 'True';
if field('series') then
this_series = field('series');
this_series_index = field('series_index');
books_in_series = book_values('title', 'series:="' & this_series & '"', ',', 0);
lowest_series_num = 999;
for title in books_in_series:
title_index = book_values('series_index', 'title:="' & title & '"', ',', 0);
if title_index < lowest_series_num then
lowest_series_num = title_index
fi
rof;
if lowest_series_num !=# this_series_index then
first_in_series = 'False'
fi
fi;
output = first_in_series