Spotfire:能否创建基于动态多限定符/图表选中项的可复用计算列
Absolutely! You can totally set up a reusable, dynamically updating calculated value (or column) in Spotfire that ties directly to your chart's X-axis selections—no need to repeat the same logic across multiple visuals. Here's a step-by-step breakdown to make this work:
First, we need a central, reusable storage spot for your selected X-axis values:
- Go to
Edit > Document Properties - Switch to the
Propertiestab, then clickAdd - Name the property something descriptive (e.g.,
SelectedXItems), choose a data type matching your X-axis column (useStringfor multi-selects—Spotfire auto-separates multiple values with semicolons) - Check
Allow multiple valuesif you want to support selecting multiple X-axis elements
Next, wire up your chart to automatically update this property when you select X-axis elements:
- Open your chart’s
Propertiespanel - Navigate to the
Actionstab, then clickAdd > Set Property - In the
Propertydropdown, pick theSelectedXItemsproperty you just created - For
Value, selectSelection, then choose your X-axis column from the list - Now every time you click or drag-select elements on the chart’s X-axis, the document property will update with your chosen values
Now you can create a calculated column (or reuse the core expression across visuals) that leverages this dynamic property. For example, if you want to calculate the sum of Y-values for your selected X-items, use an expression like this:
Sum(If([X Axis Column] In (Split(${SelectedXItems}, ";")), [Y Axis Column], Null))
- For text-based X-axis values,
Split()breaks the semicolon-separated property value into individual items for exact matching viaIn - For numeric or date X-axis columns, wrap the
Split()result in the matching type (e.g.,Integer(Split(${SelectedXItems}, ";"))orDate(Split(...)))
Save this as a calculated column once, and it will automatically update whenever your chart selections or filter conditions change.
Spotfire’s filters automatically restrict the available elements in your chart, so your selections will only come from the filtered dataset. Since the document property updates based on the chart’s current visible selections, your calculated column/expression will adjust automatically as you apply or remove filters—no extra work needed.
Want to use this calculated value in other charts, KPI cards, or tables? Just reference either the calculated column you created, or directly use the ${SelectedXItems} property in custom expressions for those visuals. For example, a KPI card can display Sum([Your Calculated Column]) to show the total for your selected X-items, with zero manual updates required.
内容的提问来源于stack exchange,提问作者NightLearner

