Jump to content

Sum value with conditions in other columns give by the treated row for over rows


Sylvain Clement

Recommended Posts

Hello,

I want to sum value where conditions are gives in the row (yellow in picture) to select over rows which have to be sum. The two columns "RankMove PM n-1" and "RankMove PM" are conditions for over rows. The sum have to sum only rows where EQTNAME is the same.

If NAME_PM is null, sum = 0

else

sum "trackout" if "RankMove" > "RankMove PM" and "Rankmove" < "RankMove PM n-1"

Someone has an idea Is it possible in spotfire to make this

It's like a SumIf in excel.

Thanks a lot for your help ! :-)

Link to comment
Share on other sites

It doesn't work, I think that the conditions for rankmove are execute only on the selected row. In a "Sumif" excel, the sum is on all rows and conditions of Sumif are in the selected row.

 

I try to make this with Python script because I am not sure that it's possible with Calculated Column.

 

I don't know python so it's taking time !!

Link to comment
Share on other sites

The closest I got was using an expression to bucket the rows :

SN(Last([RankMove PM n-1]) over (allPrevious([RankMove])),0)Then using the following expression to sum each group

Sum([Trackout]) OVER (intersect([bucketRank]))I was having trouble getting it completely accurate as your some row items would fall under multiple buckets. But hopefully this helps you get started.

Link to comment
Share on other sites

Attached you can find a solution where I didn't use your RankMove columns.

I used the cummulative sum and then transformed your data table. Then using a OVER Intersect() function to get the value from the next PM. It's important to know that Intersect functions need a continous scale, so I had to calculate a rank for each PM first.

All this can probably also be done in your original data table without my transformation. But I already spent too much time on this. You'll get this done! ;)

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...