![]() |
#1 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,948
Karma: 74999999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Template: Displaying only non-zero values
Is this the best way to do it for a composite column?
Code:
program: x = $$#integer; if x !=# 0 then x fi Last edited by ownedbycats; 03-31-2021 at 04:35 AM. |
![]() |
![]() |
![]() |
#2 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,948
Karma: 74999999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I noticed this displays 'none' for an undefined.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
cmp(t = $#myint, 0, t, '', t) Last edited by chaley; 03-31-2021 at 06:19 AM. Reason: Fix the template |
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
It doesn't for me. The 'none' value gets turned into zero for arithmetic comparisons so you should see only numbers in the 'then' clause.
But after the 'if' the variable 'x' will contain 'none'. If you don't want that then use Code:
x = raw_field(#myint', 0) |
![]() |
![]() |
![]() |
#5 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,948
Karma: 74999999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 937
Karma: 53902736
Join Date: Jun 2015
Device: multiple
|
Hi, I have a #ratio column:
program: format_number(divide(booksize(),add(raw_field("#pa ges"),1)),"{0:,.0f}") How could I amend that to avoid showing values of 0 or none? |
![]() |
![]() |
![]() |
#7 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: s = divide(booksize(),add(raw_field("#pages"),1)); cmp(s, 0, '', '', format_number(s,"{0:,.0f}")) |
|
![]() |
![]() |
![]() |
#8 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 937
Karma: 53902736
Join Date: Jun 2015
Device: multiple
|
Thanks. I got mixed up, the tricky one is #pages which uses the Count Pages plugin.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using built-in template functions in a custom template function | ilovejedd | Library Management | 4 | 01-28-2018 12:20 PM |
Use column values to determine author link template? | eosrose | Calibre | 3 | 08-24-2013 12:34 AM |
Display template values not saved to metadata.calibre | meme | Devices | 2 | 02-13-2011 01:27 AM |
displaying multiple values in the same column beneath each other | Firedancer885 | Calibre | 2 | 11-27-2010 03:13 PM |