View Single Post
Old 11-04-2019, 05:01 AM   #1
mopkin
Junior Member
mopkin began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Nov 2019
Device: none
A little help with template functions in a composite column, please!


I am not a programmer, and I am stuck with the template in a custom column I am trying to create. I was hoping, someone here could help me.

I have 2 custom columns which I use as source of data for the third column. Column_1 is looking for PDFs in book formats, and when PDF is not present, returns N/A. Here's the expression: {formats:contains(PDF, , N/A)}

Column_2 is a regular text column with permitted values, which has only one value: Yes. (Or empty, if it's a No). This is a "manual" column, where I myself select Yes when needed.

Column_3 derives its values from the first two columns, either Yes, or N/A. I used the example of a relevant expression in the Calibre Manual online and came up with this: {#column_2:'ifempty($, field('#column_1'))'}. It works perfectly fine, correctly returning either Yes, or N/A, or empty.

What I am struggling with, is the empty in Column_3. I would like it to say No, so that the column always has a value, either Yes, or No, or N/A. But as I said, I am not a programmer, so I wasn't able to fix the expression for column_3, so it would return a No when Column_2 is empty.

It is always possible to add a No to Column_2, but I would rather avoid it, because Yes is a very rare occurrence, and it would mean I would have to manually add a No to every other book, when there might be a much easier solution. I would really appreciate if someone with the knowledge of Python (I am assuming, the expression above is in Python) could help me out with this.
mopkin is offline   Reply With Quote