There is a plugin to count the books of an author "Author Book Count"
Or else you could put aside the forms that I recommend @chaley, I use one that he surely would have made taking into account the column of the count of books by author and in the detail of the book it gives you the information if that book belongs to a series:
Code:
python:
def evaluate(book, context):
# Use the built-in template function to format the title and authors
x = context.funcs.template('{Title} - {authors}')
# Count the books in the series. First get the series name
series = book.get('series')
if series:
# The book is in a series. Get the count of books in that series
db = context.db.new_api
series_id = db.get_item_id('series', series)
book_count = len(db.books_for_field('series', series_id))
# Add number of books to title - author string
x = x + f' -- From the series "{series}, which has {book_count} book{"s" if book_count > 1 else ""}'
else:
x = x + " -- This book does not belong to a series"
return x