Instead of
Code:
{#fandom:'test($, $, field('authors'))'}
use
Code:
{#fandom:'
ifempty(
sublist($, 0, 1, ","),
field("authors")
)
'}
which should use
sublist to return the zeroth through first items in #fandom, assuming they are separated by "," and ifempty, returning the authors field instead.
EDIT: This code block takes up several lines, but only because I wanted to make it clear what is going on -- I like to indent and put each section on its own line. It may actually be MORE readable in calibre if it is all one line; this works too:
Code:
{#fandom:'ifempty(sublist($, 0, 1, ","), field("authors"))'}