Search code examples
spotfireintegral

How to Calculate Area Under the Curve in Spotfire?


Can someone assist me in calculate the area under the curve in Spotfire w/o using R or S+?

I am looking to rank the data in [K] (1 = largest value) for each Well, and then calculate the cumulative sums of [P] (ranked by descending K) and [K], then calculate and plot (as curves) the % cumulative sum of [P] and [K], calculate the area under each curve, for each Well (what is the expression).

I would like to calculate each column in Spotfire, but my main problems are ranking [K] so there are no ties (I was attempting to Rank first by [K] and then by [Depth]), summing the values of [P] and [K] by ranked [K] for each Well, and then calculating the Riemann Sums (Area) under each curve.

Data_Table_and_Curves


Solution

  • At first you need to add a new column ([period]) to calculate a unique time, otherwise Spotfire would get confused of different times in the datasets:
    [well] & Log10([time] + 1)

    Then add a cross table, drag [well] to the vertical axis, and enter this expression to cell values: Sum(([pressure] + Avg([pressure]) over (Next([period]))) / 2 * (Avg([time]) over (Next([period])) - [time]))

    Alternatively you can add a new column ([AUDPC_helper]) too see step by step calculations:
    ([pressure] + Avg([pressure]) over (Intersect(NextPeriod([period]),[well]))) / 2 * (Avg([time]) over (Intersect(NextPeriod([period]),[well])) - [time])
    Just need to get summary of this column in e.g. a cross table

    enter image description here