Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 06-02-2026, 12:05 PM   #1
whiteowl
Enthusiast
whiteowl began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Jan 2020
Device: none
How to sort on Read Progress column?

Looking at "Read Progress" column defined as
Code:
{id:reading_progress(,percent)}
It shows a correct percentage as reported by the Viewer.

How to sort on this column? Clicking on column header does nothing.
whiteowl is offline   Reply With Quote
Old 06-02-2026, 12:27 PM   #2
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 75,704
Karma: 320245586
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
I don't have it displaying as a percentage, just a floating point number (synced from justRead.app) that goes from 0 to 100.

It sorts for me when defined that way.
pdurrant is offline   Reply With Quote
Advert
Old 06-02-2026, 03:07 PM   #3
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 52,374
Karma: 180944990
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
I use a column with data from my Kobo ereaders which displays integers from 0 to 100. I don't bother adding a % sign.
DNSB is offline   Reply With Quote
Old 06-03-2026, 12:37 PM   #4
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,350
Karma: 1436993
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
Quote:
Originally Posted by whiteowl View Post
Looking at "Read Progress" column defined as
Code:
{id:reading_progress(,percent)}
It shows a correct percentage as reported by the Viewer.

How to sort on this column? Clicking on column header does nothing.
I think that's a bug. Maybe @Kovid can confirm.
When I change the column definition to sort as text, then it sorts (but doesn't help us, because you will get something like 95%, 90% 9% 85% 8%, etc). It should sort as numbers.
thiago.eec is offline   Reply With Quote
Old 06-03-2026, 08:18 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 46,303
Karma: 29630860
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It's possible the sort by numbers code doesnt like the trailing percent, remove it. This is chaley's code so I dont recall off the top of my head if that's the case or not.
kovidgoyal is offline   Reply With Quote
Advert
Old 06-03-2026, 09:31 PM   #6
whiteowl
Enthusiast
whiteowl began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Jan 2020
Device: none
Quote:
Originally Posted by kovidgoyal View Post
It's possible the sort by numbers code doesnt like the trailing percent, remove it. This is chaley's code so I dont recall off the top of my head if that's the case or not.
The percent sign comes from the function {id:reading_progress(,percent)} it cannot be removed that easily. But the primary issue that Calibre does not even attempt to sort the column.
whiteowl is offline   Reply With Quote
Old 06-03-2026, 10:02 PM   #7
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,807
Karma: 64144480
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by whiteowl View Post
The percent sign comes from the function {id:reading_progress(,percent)} it cannot be removed that easily. But the primary issue that Calibre does not even attempt to sort the column.
The column is ASCII (text) the % breaks being a number as text. BTW Text sort usually need padding 01, 02... or you get 1,10,100, 2, 20, 200
theducks is offline   Reply With Quote
Old 06-04-2026, 12:42 AM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 46,303
Karma: 29630860
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Not sure what the difficulty in removing the % is. Use one of the string manipulation functions to remove it or use pos_frac instead of percent to get a pure number.
kovidgoyal is offline   Reply With Quote
Old 06-04-2026, 08:52 AM   #9
whiteowl
Enthusiast
whiteowl began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Jan 2020
Device: none
I do not want to use `pos_frac` since the function knows `percent` and it looks much nicer and cleaner than a fraction.

The `%` sign is printed by the function itself. Do not see how to remove it, and why should I do it in the first place, since the percentage is the value I want to see.

Yes, if the column would have
Code:
Sort/search column by: Text
The column become sortable and do a sort as expected by alphabet: 1%, 10%, 2%, etc...
But if the "Sort/search column by:" is set to Number - the click on column header does nothing.

So I see here two ways to solve this issue:
- Add a separate field "sort by function" in parallel with field Template (which defines what is shown in the column). And the new function will be used for sorting.
- Fix sorting of percentage as a number, since it is really a number.
whiteowl is offline   Reply With Quote
Old 06-04-2026, 10:37 AM   #10
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,350
Karma: 1436993
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
I think the problem is that the template is returning a string when you choose 'percent'. I have a custom column with my reading percentage, but it was created as a 'Floating point number' and I added this formatting: {:.0f}%. It sorts just fine.

I don't know how difficult it would be, but the best-case scenario would be for the template to return a formatted floating point number.

For now, you can use the template below to activate sorting:
Code:
program:
	format_number(reading_progress($id, '', 'pos_frac')*100, '{:.0f}')
You will get the same as using 'percent' minus the '%' symbol. And now you can sort.
thiago.eec is offline   Reply With Quote
Old 06-04-2026, 10:52 AM   #11
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 46,303
Karma: 29630860
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@whiteowl I have no idea why you are being so argumentative. If you want it to sort numerically, it needs to be a number. pos_frac gives you a number. percent does not. If you prefer a percentage number to look at such as 23 instead of 0.23 then chain two functions to remove the trailing percentage from the result of reading_progress(). That way you get both a nice percentage number to look at and it will sort by that number as well. In any case, my patience is exhausted, good luck.

@thiago.eec: All template functions operate on and return strings. Numerical sorting simply re-interpretes those strings as numbers.
kovidgoyal is offline   Reply With Quote
Old 06-04-2026, 11:19 AM   #12
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 75,704
Karma: 320245586
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
It sounds like you could redefine your progress column to be a pure number, and then use a display format for the column to add a % at the end when it's displayed, rather than having the % in the column data itself.
pdurrant is offline   Reply With Quote
Old 06-04-2026, 11:20 AM   #13
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,350
Karma: 1436993
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
Quote:
Originally Posted by kovidgoyal View Post
@thiago.eec: All template functions operate on and return strings. Numerical sorting simply re-interpretes those strings as numbers.
I see. I didn't know that.
thiago.eec is offline   Reply With Quote
Old 06-04-2026, 05:21 PM   #14
whiteowl
Enthusiast
whiteowl began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Jan 2020
Device: none
Quote:
Originally Posted by thiago.eec View Post
I think the problem is that the template is returning a string when you choose 'percent'. I have a custom column with my reading percentage, but it was created as a 'Floating point number' and I added this formatting: {:.0f}%. It sorts just fine.
Sorry, I do not understand how you did it.

When I click on "Read Progress" template - it creates a "Column type: Column built from other columns". There is no field for formatting.
Attempt to change that column type to Float, adds a field "Format for numbers", but removes the "Template" field with the function.

So: how do you format the "Column built from other columns"?

Quote:
Originally Posted by thiago.eec View Post
For now, you can use the template below to activate sorting:
Code:
program:
	format_number(reading_progress($id, '', 'pos_frac')*100, '{:.0f}')
You will get the same as using 'percent' minus the '%' symbol. And now you can sort.
Again: How? What should I click in the UI to get to the field where I would be able to type that expression?
whiteowl is offline   Reply With Quote
Old 06-04-2026, 05:33 PM   #15
whiteowl
Enthusiast
whiteowl began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Jan 2020
Device: none
Quote:
Originally Posted by kovidgoyal View Post
@whiteowl I have no idea why you are being so argumentative. If you want it to sort numerically, it needs to be a number. pos_frac gives you a number. percent does not. If you prefer a percentage number to look at such as 23 instead of 0.23 then chain two functions to remove the trailing percentage from the result of reading_progress(). That way you get both a nice percentage number to look at and it will sort by that number as well. In any case, my patience is exhausted, good luck.
I do not want it to sort numerically. I want to see the same percentage as it is shown in bottom-right corner of the Viewer, and I want that column to be sortable as any normal human does sort percentage values. That is all I want.

Currently, Calibre UI does not do it from the box, and all my attempts of customization is failing.

But if your patience is exhausted, I guess, I can do nothing else. Sorry to bother you.
whiteowl is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort by author and then publish date (multi-column sort)? badbob001 Library Management 7 07-22-2020 06:45 PM
Trying to make a percentage progress composit column. Kythe42 Library Management 13 12-26-2019 05:14 PM
Column built from other column : Mark read if evaluated Cmely Library Management 1 02-26-2017 09:07 AM
Manual Sort or Sort by custom column Dethmaul Marvin 2 04-28-2014 11:54 AM
Multi column sort? nexus100 Calibre 1 07-11-2010 11:19 PM


All times are GMT -4. The time now is 10:38 AM.


MobileRead.com is a privately owned, operated and funded community.