I'm attempting to display word_count with "K" and "M" suffixes for thousands and millions, respectively. However, I'm encountering an issue saying "TEMPLATE ERROR could not convert string to float". How can I fix the template to work as intended?
Code:
program:
switch(
field('#word_count') >= 1000000, format_number(field('#word_count') / 1000000, '{:.1f}') + ' M',
field('#word_count') >= 1000, format_number(field('#word_count') / 1000, '{:.1f}') + ' K',
field('#word_count')
)
Another question. If I were to ask this on Codidact or StackOverflow, what tags should I use? Should I tag it as `calibre template`, or is there a programming language that uses the same syntax that I should tag instead?