|
|
#1 |
|
Enthusiast
![]() 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)}
How to sort on this column? Clicking on column header does nothing. |
|
|
|
|
|
#2 |
|
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
|
|
|
|
|
#4 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,350
Karma: 1436993
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
Quote:
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. |
|
|
|
|
|
|
#5 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Enthusiast
![]() Posts: 40
Karma: 10
Join Date: Jan 2020
Device: none
|
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.
|
|
|
|
|
|
#7 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
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
|
|
|
|
|
|
#8 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
|
|
|
|
|
#9 |
|
Enthusiast
![]() 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 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. |
|
|
|
|
|
#10 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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}')
|
|
|
|
|
|
#11 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
|
|
|
|
|
#12 |
|
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
|
|
|
|
|
#13 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,350
Karma: 1436993
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
|
|
|
|
|
|
#14 | |
|
Enthusiast
![]() Posts: 40
Karma: 10
Join Date: Jan 2020
Device: none
|
Quote:
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"? Again: How? What should I click in the UI to get to the field where I would be able to type that expression? |
|
|
|
|
|
|
#15 | |
|
Enthusiast
![]() Posts: 40
Karma: 10
Join Date: Jan 2020
Device: none
|
Quote:
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. |
|
|
|
|
![]() |
|
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 |