Spotfire调试经验——动态平均值的计算及动态基准线的绘制(Dynamic average value calculation and benchmarking in Spotfire v

很久以来都想找到动态基准线的绘制方法,今天终于找到方法了。真是“众里寻他千百度,蓦然回首,那人却在灯火阑珊处”。

平均销售额的直方图如下所示:


Spotfire调试经验——动态平均值的计算及动态基准线的绘制(Dynamic average value calculation and benchmarking in Spotfire v

问题:如何将销售额的当期平均值与其父节点(Parent Node,如,月度的父节点为季度,季度的父节点为年度)的平均值进行比较。也就是如何画出一条基准线,方便进行比较?

解决方案:单击图标左侧Y轴平均销售额的上方新建一个指标(column,这个column不是原生列,也不是calculated column,而是通过表达式生成的自定义列),编辑公式为

avg([Sales Total]) over (Parent([Axis.X]))”,即可实现该需求。


Spotfire调试经验——动态平均值的计算及动态基准线的绘制(Dynamic average value calculation and benchmarking in Spotfire v


Spotfire调试经验——动态平均值的计算及动态基准线的绘制(Dynamic average value calculation and benchmarking in Spotfire v


Spotfire调试经验——动态平均值的计算及动态基准线的绘制(Dynamic average value calculation and benchmarking in Spotfire v


----------------------------------------------------------------------------------------------------------------

以下内容节选自官方文档:

The OVER functions are used to determine how data should be sliced, for example, relative to time periods. For more information, see OVER in Custom Expressions and Advanced Custom Expressions.

Option: Parent

Uses the parent subset of the current node. If the node does not have a parent, all rows are used as the subset.

 Examples:

Sum([Sales]) / Sum([Sales]) OVER (Parent([Axis.Color]))

Sum([Sales]) / Sum([Sales]) OVER (Parent([Axis.X])) * 100

以下内容为培训资料中的说明:

You can't really talk about the Parent() function without firsttalking a little about data hierarchies.



Implicit Data Hierarchies
When you place columns side by side on an axis, this is an implicit data hierarchy.  The values in the right columns become grouped by the values in the left columns.

By default, the right-most column in an implicit hierarchy is where node navigation begins in an OVER statement.




Explicit Data Hierarchies

You can explicitly create hierarchies out of time columns or anyset of columns in the dataset.  Explicitly created hierarchies havespecial nested checkbox query devices and special "slider" columnselectors when added to plots.

By default, the current slider position of an explicit hierarchyis where node navigation begins in an OVER statement.




Hierarchies and Dynamic Expressions

The Parent() method is how you can navigate up one level in a data hierarchy when writing a dynamic expression with an OVER statement. The Parent() method works just as well on both implicit and explicit data hierarchies as plot properties.


The Parent() method will navigate up one level of the hierarchy from the current position.  If there is no hierarchy or the hierarchy is already at the top level, the Parent() method behaves effectively like the All() method.