The correct query is
Code:
program: book_count('publisher:=' & $publisher & '"', 0)
This template could be too slow to use in a composite column. You can use it in action chains to set the count.
This python template should be fast enough to use directly in a composite
Code:
python:
def evaluate(book, context):
db = context.db.new_api
pub_id = db.field_ids_for('publisher', book.id)
if not pub_id:
return '0'
pub_id = pub_id[0]
counts = db.get_usage_count_by_id('publisher')
return str(counts[pub_id])