aai agency logo
Newsletter header images

Data Function Basics in Spotfire

November 04, 2025

Choose Your Learning Style

Select an option to view the article tailored to your learning style

  • Technical

    For those who want to dive deep into the technical details

  • Curious Learner

    For those who want to understand the big picture

  • Short on Time

    Few minutes read that gives you the high-level points


Technical TLDR:


You can watch the full video below.




  • What Data Functions Are: Data functions allow you to run Python or R directly inside Spotfire by passing in tables, columns, and document properties as inputs, running whatever logic you need in a script, and then sending the results back to Spotfire as new tables, values, or document properties.


  • Why They Matter: They give you a clean way to centralize logic, run transformations, perform advanced calculations, integrate external services, and prototype app-like workflows without relying on layers of calculated columns or complex expressions.


  • How They Work:You map inputs from your dashboard into the function, write your Python or R logic, and then map your outputs back into Spotfire objects. Each time the function runs, it processes the data based on the latest state of the dashboard.


  • What This Unlocks: Once you understand the pattern, you can build rapid internal tools, automate heavy workflows, reshape data on the fly, and create a deeply interactive user experience inside Spotfire.



Spotfire Data Functions: A Clean Way to Run Real Logic Inside Your Dashboard


Data functions are one of those features that sit quietly in Spotfire, and most people don’t truly appreciate what they can do because the setup looks a little intimidating at first glance. But once you understand their structure, they become one of the most reliable ways to organize logic inside a dashboard, especially when you're building tools that need to do more than what a standard calculated column or custom expression can handle.


The easiest way to think about a data function is that it sits between Spotfire and whatever logic you want to run. Spotfire gives you the inputs, whether that’s a table, a column, a document property, or even a subset of marked data. Your script does the work, filtering, aggregating, running anomaly detection, applying business logic, or even reaching out to an external API, and then Spotfire captures the outputs and updates your visuals instantly. Once you understand that flow, the whole feature becomes a lot less mysterious.



Inputs, Logic, and Outputs


At the core of every data function is a simple but powerful structure: Spotfire provides the inputs, you write the logic, and Spotfire maps the outputs back into the dashboard.


Inputs can be anything Spotfire exposes.


You can pass in a full data table, a filtered subset, a specific column, or even just a document property the user typed into a text area. Spotfire treats each of these as a named object, and once you assign that name, you can reference it directly inside the Python or R script.


Logic is whatever your workflow requires.


Because this is real Python or R, you have full control over how the data is shaped. You can add new columns, clean the data, run machine learning models, compute forecasted values, run economics, or simply apply a transformation. Spotfire hands you a pandas DataFrame when you pass in a table, so everything behaves exactly as you'd expect in a normal Python environment.


Outputs are how you push the results back into your dashboard.


You decide whether the script returns a new document property, a new table, or updates an existing one. Spotfire handles the mapping for you, so you always know exactly where your results will appear. This structure makes the logic highly reusable and a lot easier to maintain than scattering calculations across multiple layers of expressions and calculated fields.



Registering a Data Function and Understanding the Options


When you open Data → Data Function Properties, you can create a new function and walk through the setup. You select whether you want to use Python or R, specify any packages you might need if you ever plan to deploy this on your server, and write a short description of what the function does so other users understand how it fits into the dashboard.


Spotfire also gives you the option to enable caching. This simply tells Spotfire not to re-run the script if the inputs haven't changed since the last time. If the function does something computationally heavy, caching can save a lot of time because Spotfire will return the last known output instantly.


The script editor itself is fairly basic because Spotfire doesn’t offer IntelliSense or the kind of interactive development you'd get in VS Code or Cursor. In practice, most people write and test their scripts outside of Spotfire, then paste the final version back in once they’re ready. I’ll cover my full workflow for this in a separate video because it makes development significantly easier.



Setting Up Inputs


In the input section, you define the objects that your script will receive. For example, you might add an input called data, set its type to “table,” and allow it to bring in all columns. This means that inside the script, you’ll be working with a pandas DataFrame called data, which you can manipulate however you want.


Spotfire also allows you to pass in filtered rows, apply a specific filtering scheme, or pass in only marked records. This becomes very powerful when the workflow depends on the user's on-screen interaction, such as selecting wells to forecast or marking outliers before running anomaly detection.



Writing the Script


Inside the script, you can do anything you'd normally do in Python. In the simple example from the video, you created a new variable called test_property and added a new column to the DataFrame with a value of 1 for every row.


It’s a small example, but it perfectly illustrates the main idea: Spotfire hands you the data, you transform it however you want, and Spotfire will use whatever you output. This pattern is how more complex Spotfire apps are built, whether you're layering multiple data functions, orchestrating logic with document properties, or structuring entire workflows inside the dashboard.



Defining Outputs and Mapping Them Back Into Spotfire

On the output side, you define how the results of your script should return to Spotfire. This is where the mapping happens.

For example:


  • The variable test_property becomes a new document property called test result
  • The modified DataFrame becomes a new data table called data updated


Spotfire then takes over from there. It creates or updates those objects every time the data function runs. This makes it incredibly easy to see exactly what your script produced. You can open a table visualization, inspect the new column, check the document property, and confirm the entire cycle ran as expected.



Running the Function and Choosing Refresh Behavior


Spotfire gives you control over when the data function should run. If you enable automatic refresh, the function re-runs whenever the inputs change. If you're doing something heavier, like economics or forecasts that depend on multiple user inputs, you usually want the user to configure everything first and then manually click a “run” button. The decision depends entirely on the workflow.


If you're preparing this for deployment on your company’s server, the run location setting (local or server) becomes important. For now, default settings work fine, but when you start pushing these dashboards to production, you’ll want to make sure the server environment has access to the same Python packages your logic requires.



Validating the Results


After running the demonstration script in the video, Spotfire immediately generated a new table with the additional column and created a new document property with the expected value. Updating the script and clicking refresh showed that the changes took effect immediately, which confirms the full loop is wired correctly.


This is the foundational pattern for every advanced workflow you build with data functions.



Why Data Functions Matter in Real Workflows


Once you understand the mechanics, data functions become your best friend for anything that goes beyond basic expressions. They give you a clean place to put logic, and they allow you to build internal tools that behave like lightweight applications, all inside Spotfire.


You can run more structured transformations, remove layers of messy calculated columns, tie your logic directly to user inputs, build forecasting tools, integrate with external APIs, or perform processing that would never be possible in standard Spotfire expressions.


This is where Spotfire starts feeling like a proper development environment instead of just a visualization tool.



Wrapping Up


Data functions open the door to some of the most powerful and flexible capabilities in Spotfire. They let you pull in real Python or R logic, manipulate data on the fly, and return structured results back into the dashboard in a way that is repeatable, transparent, and easy to control. The moment you start using them, dashboards that once felt rigid and limited suddenly become dynamic, interactive, and capable of handling far more complex workflows.


In the next part of this series, we’ll start exploring how to build more advanced data functions, how to chain them together, and how to combine them with document properties and IronPython to build internal tools that behave like full applications.


If you want help building these kinds of workflows inside Spotfire or designing app-like tools for your teams, feel free to reach out at info@aai.agency.