简体   繁体   中英

Retrieving Value from Another Row in Spotfire

I am attempting to reference a value in another row for a particular column of data in Spotfire. As an example, I would like to reference the sales month where the quantity of sales of bronze widgets was equal to the number of Gold Widgets. I've included a column below to show the data I need, "Month Where Bronze Sales = Gold Sales"

Sales Month        Cumulative Bronze Widgets             Cumulative Gold Widgets              Month Where Bronze Sales = Gold Sales
   1/1/2017                                     0                                 1                                              2/1/2017
   2/1/2017                                     1                                 2                                              4/1/2017
   3/1/2017                                     1                                 2                                              4/1/2017
   4/1/2017                                     2                                 3                                              5/1/2017
   5/1/2017                                     3                                 3                                              5/1/2017
   6/1/2017                                     4                                 3                                              5/1/2017

I need to accomplish this with an expression without using a script or inserting another table. Is this possible? I've tried the following and other "Over" functions without success for "Month Where Bronze Sales = Gold Sales"

Case When Max([Cumulative Bronze Widgets]) over ([Sales Month])= [Cumulative Gold Widgets] Then Max([Sales Month]) Over ([Cumulative Bronze Widgets]) else NULL End

Spotfire supports getting data from another rows through OVER formulas. That requires a common value in the SAME COLUMN of the current row and the one where you get the data from.

You need to match values in different columns, so OVER won't work for you.

You can try some workarounds:

1. Separate column for each Cumulative Bronze Widgets

This works if you expect only a few numbers of Cumulative Bronze Widgets :

  • "Cumulative Bronze Widgets - 1":
    Min(IF([Cumulative Bronze Widgets]=1,[Sales Month],Null))
  • "Cumulative Bronze Widgets - 2":
    Min(IF([Cumulative Bronze Widgets]=2,[Sales Month],Null))
  • ...
  • "Month Where Bronze Sales = Gold Sales":
    Case When [Cumulative Gold Widgets] then [Cumulative Bronze Widgets - 1]
    When [Cumulative Gold Widgets] then [Cumulative Bronze Widgets - 1]
    ....
    End

2. Create a new table

  • Create a new cross table visualization for Bronze widgets vs sales month
  • save this new visualization as a new table
  • create a link between old and new tables ([original table].[gold widgets] = [new table].[bronze widgets]
  • you can now filter the original table by filtering the new one; unfortunately you can include data from multiple tables in the same visualization.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM