View Single Post
Old 07-13-2019, 01:29 AM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
I think I know what you want:

Print the reading status followed by a dash and a tag. The tag to print is the first of a set of preferred tags. And that tag is uppercased.

I have made a couple of assumptions:
- The status column always has a value
- The tag won't always be there

The first version, based on what you have done is:

Code:
{#status}{:'uppercase(first_non_empty(contains(field("tag")," - Mystery", "MYSTERY",""),contains(field("tag"),"Science Fiction", " - SCI FI","")))'}
If you are after more than two tag, then add an extra "contains". I don't like that, but, it works if you want to rename the tag to something else. The order of the "contains" are important. If you have both "Mystery" and "Science Fiction" in the tags, it will always return "MYSTERY".

A better version for adding more tags is:

Code:
{#status:}{:'uppercase(list_item(list_intersection(field("tag"),sublist("Mystery,Science Fiction",0,0,","), ","),0,","))'| - |}
With this, it finds the first match in tags or the values. That means if your tags are "Mystery,Science Fiction", the result will be "MYSTERY" and if it is "Science Fiction,Thriller,Mystery", it will be "SCIENCE FICTION". And adding another tag just means adding another to the list.

This is the version I would use as I order the tags in importance. Swapping the tag and the list of matches, would achieve the same as the first example. So:

Code:
{#status:}{:'uppercase(list_item(list_intersection(sublist("Mystery,Science Fiction",0,0,","),field("tag"), ","),0,","))'| - |}
davidfor is offline   Reply With Quote