I am considering submitting to @kovid a change to add a new search term to calibre: summarize_booklist:field_name,count, where 'field_name' is the lookup name and 'count' is optional.
This search term does the same thing as the template
in this post. Specifically it scans the current book list in order, searching for values in "field_name". If the number of value(s) already seen is less than "count" then it adds the book to the search results.
Because it scans the book list in order, you have control over which value(s) it finds first by sorting the book list before doing the search. Because it uses the book list, subsequent "summarize_booklist" searches further summarize what you see. You get back to the "full" book list (subject to VLs) by erasing the "summarize_booklist" search.
Here is an example of summarizing the book list by series. The first capture shows several series on the book list, sorted by series.
This capture shows the result of the "summarize_booklist:series,1" search:
This capture shows the result if the book list was sorted series descending before the "summarize_booklist" above was applied.
And finally, this capture shows the result of applying "summarize_booklist
ublisher,1" to the result of the previous summarize.
It isn't clear that I should propose this code. The biggest issue is that it is similar in concept to making a pivot table, but there is no way (and never will be a way) to interactively open and close the sublists. In other words, there is no "button" to show the books in theory hidden behind the displayed book.
A second issue is that as mentioned above, the summarization is cumulative. To start over one must erase the current search, or do something like open a VL that does the same thing. This behavior is different from normal calibre searches, which start over each time, ignoring what is displayed. I can't repeat that behavior so there will be confusion, and therefore posts and bug reports.
Finally, this search term works only in the GUI. Using it from the command line or calibre server won't work.
Still thinking. Your thoughts are welcome.