This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Have you ever wanted to build pieces of a report, and then save them somewhere for later use? Perhaps you have a boilerplate portion of a report, and don't want to have to construct it over and over again?
Snippets are just like any other data, with one important exception. We'll get to the exception in a minute, but for now, you can repeat the mantra "snippets are text, snippets are text, snippets are ... zzzzzzzzz ..."
Had a nice nap? Ok. Now that you're rested up, it's time to explain the exception. Snippets are text, but they are magically blessed text. But how can text be blessed, you ask? Time for a small digression:
Every field in Alteryx has metadata. Metadata is what describes (or defines, depending of your perspective) the data, but it isn't the data itself.
It is fairly easy to think of some metadata. Certainly, the field type and size are fairly obvious. This is what distinguishes the number 10 from the text "10", and what distinguishes integers from decimal values, and so on.
But there are two other pieces of metadata that you may be unfamiliar with. They are called the source and description. A field's description is simply a label that you, the user, can set using a Select tool. It makes it easy to add a notation to a field that you'll be able to see anywhere downstream from where you entered it.
The source field, on the other hand, is not something that you, the user, can touch. It is created by whatever tool creates the field, and does so in a way to tell you where the data came from. Is it a data field form Allocate? The source field will tell you which dataset. Was the field created by a Formula? The formula itself is in there. An input tool? The filename or database where the data came from.
So now that you are an expert on metadata, how does that relate to the original question? Well, the way the reporting tools bless their text output is by setting the source field (remember? tools which create fields set their source) to something beginning with "Report:". It is by this simple act that the text field becomes blessed. It is also why you can't modify a snippet in, say, a Formula tool. After all, the Formula tool will replace the source field, and then it is back to being a heathen string. And here is where the problem occurs.
When you read data from a datafile (using and Input tool, for example), the source metadata for each field is set to tell you which file (or datasource) the data came from. So if you write a snippet to an SQL database, or Excel, or what have you, the magical blessing gets lost. When you read it back in, it is still the same snippet, but Alteryx doesn't know that.
Luckily, there are two solutions for this. First and foremost, are the amazing fantastical YXDB data files. Not only are these incredibly efficient for storing your data, they are also smart. YXDB files store metadata. That means that when you write data into them and read it back out, the source and description fields survive the round trip. That means that snippets written to a YXDB file remain snippets when they are read back out. Simple and elegant.
But what if you must use one of those other file or database formats? Well, fear not. If you have a text string that you know, deep in your heart, really is a valid snippet, you san use the following trick to bless it yourself. But be warned -- Alteryx is relying on you to be truthful and honest. If it isn't a valid snippet, your report could come crashing down around you. So no willy nilly blessing.
To bless a text string, put it through a Reporting Text tool. Set the tool to "Expert Mode", and set the text to just the original field. For example, if the original field from the database was named MySnippet, set the text to [MySnippet]. Expert mode means that the tool will not provide any extra "decoration" around what you specify. So the upshot of this is that the new field coming out of the Text tool will contain exactly the same content that came into it. But because it will be in a new field, and because the new field was created by the Text tool, it is thus blessed.
And so all is right in the world once again. Or something like that.
*Here is the partial list of blog titles which didn't make the cut: