- Would you like to create a new table based on unique values from a different table?
- Would you like to learn how to reference a column in a TERR data function?
- Are you combining data from different sources and having problems with duplication?
I am currently working on a project that joins oil and gas header data from three different data sources (via an insert rows operation). Then, that data gets put onto a map. The user marks the map, which then executes an on-demand query to pull in the production data for only marked wells. With this architecture, the file opens quickly and only brings in production data for the wells needed.
This is a pretty good architecture and workflow with one problem. The problem is the wells can be on the map three times. When the user marks the map, Spotfire generates an on-demand query that may include duplicate API numbers. That’s inefficient. I even went into the SQL logs to look at the query generated, and I found those duplicates.
I can still use my existing architecture and improve the project by using a TERR data function to create a list of unique APIs from the master header table. Then, I can populate the map from this new, smaller table. Users will still mark the map, but when they do a more efficient query is generated.
All it takes is a simple line of code using the unique function. Now, if you’ve never created a TERR data function before, I suggest this read on TERR basics. I’m not going to show every TERR screen, but if you understand the basics explained in that post, you’ll be fine. Here is what the code looks like.
uniqueAPI10 <- unique(c(masterheader$API10))
After clicking run, Spotfire will ask you to map the parameters to the data. I mapped the
All said and done, this is a simple example, but it shows you how to use a R/TERR function and access a specific column of data.
Content created with Spotfire 7.12.