View Single Post
Old 07-31-2025, 12:14 PM   #1
Far_Pen_6884
Enthusiast
Far_Pen_6884 began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Jul 2025
Device: paperwhite
Question How to Display Word Counts in Thousands and Millions in Calibre?

Hey everyone,

I'm trying to display word counts from FanFicFare in Calibre with both "K" for thousands and "M" for millions (e.g., 1500 as 1.5K, 34267 as 34.3K, 1234567 as 1.2M). I've seen solutions for thousands, but I'm not sure how to extend this to millions. Any tips or tricks would be greatly appreciated!

Thanks in advance for any help!

Here are a couple of solutions I found for displaying word counts in thousands:

#### Reddit Solution

From [Reddit](https://www.reddit.com/r/Calibre/com...ers/mf54thv/):

1. **Create a usual integer custom column** (e.g., named `wordcount`) to store the raw word count numbers filled by FanFicFare.
2. **Don't display this raw word count column** directly.
3. **Create a second custom column of type "Column built from other columns"** to format the display.

Use this composite template to show the word count simplified as thousands with one decimal and a "K" appended:

```plaintext
program: format_number(divide(field('#wordcount'), 1000), '{:.1f}K')
```

Explanation:
- `field('#wordcount')` reads the value from the column named `wordcount`.
- `divide(..., 1000)` divides the value by 1000 to convert to thousands.
- `format_number(..., '{:.1f}K')` formats the number with one decimal place and then appends "K".

For better sorting by number, instead of including "K" in the formatted string, use:

```plaintext
program: format_number(divide(field('#wordcount'), 1000), '{:.1f}')
```

and in the column settings, set **"Sort/search column by" -> "Number"**. This preserves numeric sorting by thousands. You can name this column "Length" or "Word Count (K)".

#### MobileRead Solution

From [MobileRead](https://www.mobileread.com/forums/sh...php?t=340393):

A related example from MobileRead shows a simple template solution for 1.5k format using Calibre's program template syntax to do calculations manually:

```plaintext
program:
before = round($$#words/1000);
after = round(($$#words - (before*1000))/100)*0.1;
complete = before + after
```
Far_Pen_6884 is offline   Reply With Quote