![]() |
#1 |
Member
![]() ![]() Posts: 12
Karma: 132
Join Date: Aug 2011
Device: Kindle Voyage, Kindle Paperwhite
|
Help Formatting Custom Column
I built a custom column and got that to do what I intended but the resulting number is probably 15 to 20 digits long. I'm trying to shorten it to just one digit after the decimal (0.1). I have two sets of code that do what I want that I will post in case one works better with formatting. I've looked around to try figuring it out and it seems like {0:.1f} should do what I want, but I have no clue where it would go. Any help is greatly appriciated!
Code:
{#kudos:'divide(multiply($, 100), field('#hits'))'} program: kudos = field('#kudos'); hits = field('#hits'); percent = multiply(kudos, 100); divide(percent, hits); |
![]() |
![]() |
![]() |
#2 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 71
Karma: 2202292
Join Date: Nov 2018
Device: Kobo Libra 2
|
Try this:
Code:
program: kudos = field('#kudos'); hits = field('#hits'); percent = multiply(kudos, 100); format_number(divide(percent, hits), '{0:.1f}') ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Member
![]() ![]() Posts: 12
Karma: 132
Join Date: Aug 2011
Device: Kindle Voyage, Kindle Paperwhite
|
Unfortunately that just shows the solution followed by the entire code written out. This is where I was getting stuck. I've been reading through that page and I've been trying things but I'm still suck between finding the right thing to do what I want and how to properly use it to make it work.
![]() |
![]() |
![]() |
![]() |
#4 |
Member
![]() ![]() Posts: 12
Karma: 132
Join Date: Aug 2011
Device: Kindle Voyage, Kindle Paperwhite
|
Never mind! It was missing a ; at the end. It works perfectly now!
![]() |
![]() |
![]() |
![]() |
#5 | |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 71
Karma: 2202292
Join Date: Nov 2018
Device: Kobo Libra 2
|
Quote:
![]() For future reference, when you're editing a custom column and things aren't working I find it helpful to open the Template Editor or whatever it's called (which for some reason isn't really advertised anywhere on the help page...) To access it, just highlight a book row in your library and click on the custom column entry (as if you were going to edit the entry if it was a simple column like title, author etc) and the editor should pop up and look like the attached pic. It updates in real time so you can play around with the coding to get it to work |
|
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Price Custom Column Formatting Help | PaulineDesigns | Library Management | 13 | 07-22-2022 09:23 PM |
Help formatting default value of custom column | MerlinMama | Library Management | 2 | 08-28-2020 11:45 AM |
Using RE to extract pattern from custom column into another custom column | activedirectory | Library Management | 1 | 12-15-2019 08:07 PM |
Custom column returns value based on value of another custom column? | calvin-c | Calibre | 3 | 09-14-2013 02:24 PM |
Formatting Floating Point # Custom Column | GeekyGal | Library Management | 3 | 06-03-2011 05:34 PM |