Number of Successive Cells of a Same Value in Spotfire

◇◆丶佛笑我妖孽 提交于 2019-12-12 01:45:04

问题


I am wondering if it is possible to created a calculated column that will count how many cells of the same value are successive (i.e., next to each other) so that I can divide it by the total number of cells in that column. (I'm only looking at 1's and 0's in the column. Any help or advice would be greatly appreciated as I've been scratching my head over this for a while,

The percentages at the bottom of the columns is simply = (the number of 1's touching another 1) / (total # of rows) --> my end goal


回答1:


Ok this has to be done in a few steps.

  • Insert a calculated column RowId() and name it rid
  • Insert a calculated column with this expression, and name it [TouchingA]:

If(([Location A]=1) and (([Location A]=First([Location A]) over (Next([rid]))) or ([Location A]=First([Location A]) over (Previous([rid])))),1,0)

  • Insert a calculated column with this expression, and name it [TouchingB]:

If(([Site B]=1) and (([Site B]=First([Site B]) over (Next([rid]))) or ([Site B]=First([Site B]) over (Previous([rid])))),1,0)

At this point, your data will look like this:

Next, insert a CROSS TABLE and set the Horizontal Axis = (Column Names), the Vertical Axis = (None), and the Cell Values = Sum([TouchingA]) / Max([rid]) as [A Percent], Sum([TouchingB]) / Max([rid]) as [B Percent]

This will show you the values you want, like below. Of course you can sett his in a calculated value in a text area or anywhere else you want with the proper IF or CASE statement. Lastly, you can change the formatting to make the value a % versus decimal.



来源:https://stackoverflow.com/questions/38569102/number-of-successive-cells-of-a-same-value-in-spotfire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!