Thursday, August 10, 2017

Create custom facet names by using an if function

 I covered custom faceting using booleans in this post. The other nice feature with custom facets is that if you don't want the labels "true" and "false" for your facet, you can just drop your boolean into an if function, and you can name your own facets.

In the custom facet I created using booleans, I used this piece of GREL to facet out any 856 |3 data that started with a volume label and didn't have a semi-colon:

and(value.startsWith("v"), not(value.contains(";")))

 

If I wasn't satisfied with the "true" and "false" names for my facets, I could instead create a custom facet where the data I want is called "volume" and the data I didn't want is called "other". If you remember, an if function is if(<boolean test condition>, <execute GREL if true>, <execute GREL if false>)

The <execute> parts in this case are just the names you want to use for your two facets. So, if I drop in my custom facet names into the if function, it becomes:

if(<boolean test condition>, "volume", "other")

Then all I have to do is drop in the boolean I used for the true/false facet:
if (and(value.startsWith("v"), not(value.contains(";"))), "volume", "other")












And here's the facet:




No comments: