Writing Calculations Against Untagged Records

  • Would you like to know how to use tags and tag collections?
  • Are you using tags and tag collections to create custom groupings?
  • Did you know creating a tag collection creates a new column of data in the table?
  • Would you like to flag records in a table that are Untagged?

I ran into an issue this week with a user who wanted to create a calculated column to flag Untagged records in a table.  Now, if you have never used tags or tag collections before, you’re missing out on a great feature in Spotfire.  A tag collection contains one or more tags that are attached to marked records.  Tags may be used for many things including creating custom groupings of data when you don’t have a column of data with useful unique values.

Before I dive into the calculation, I’ll explain how to create a tag collection and tags. Then, I’ll provide the solution for the calculation.

Creating a Tag Collection and Tags

Creating a tag collection and associated tags is a 4 step process.

  1. Open the tags panel by clicking on the tags button in the taskbar.   
  2. Create a tag collection by clicking on the ‘Create tag collection’ button. 
  3. Once the tag collection is open, name the collection and create the tags.  You can also use the button to the right of the ‘Create tag collection’ button in the tags panel. 
  4. Attach marked rows to the tag by marking, right-clicking the tag, and selecting ‘Attach tags to marked rows’.  The tag will indicate how many rows are attached to the tag.

That’s the quick and dirty of creating tag collections and tags. If you would like more information on tags, take a look at this post, which explains the difference between bookmarks, tags, and lists, and should give you a good idea of what you can accomplish with tags.

Now, creating a tag collection also creates a new column of data in the table and will be visible in the Filter panel as shown here.  That column may also be used in calculations, which is where we are going next.

Calculation for Untagged Rows

As you can see in the Tags panel, all of the tags are shown, as well as a line item for untagged rows.  The user I was working with wanted to create a calculated column that would flag unmarked rows.  You might be asking — why didn’t the user use the tag collection column?  There was a reason, but it’s been a long week, and I don’t remember what it was (honest answer), so I am just going to focus on the question on at hand — how do we capture Untagged records in a calculation?

Based on the Data panel, you might think something like this — if([Well Groupings] = “Untagged”, 1, 0) — would work.  The Data panel does list “Untagged” as a unique value.  However, that will expression will result in null.

In actuality, Untagged = null, so it needs to be referenced as shown below, as a null.

And that is how you reference Untagged records in calculated columns.

Spotfire Version

Version 7.12 used to create this content.

Guest Spotfire blogger residing in Whitefish, MT.  Working for SM Energy’s Advanced Analytics and Emerging Technology team!

Leave a Comment

Your email address will not be published. Required fields are marked *