Search code examples
spotfiredata-transform

spotfire calculated column using over function


I want to create a calculated column "indicateur" that traces the boolean values when I have a True, I increment the indicator by 1, however i want the false rows to have the value of the last true indicator.

and when i pass to a new ID, the incrementation starts from zero.

I already tried some spotfire expression using the over function but not getting the right results

case  
when [boolean] then sum(If([boolean],1,0)) over (Intersect([ID],AllPrevious([ID])))
else 0
end

enter image description here


Solution

  • You have a couple of issues here. Your case statement is sub setting the data... it will only calculate sums where boolean is true.

    The main issue is the over statement though. Something like this should give the correct answer

    sum(If([boolean],1,0)) over (Intersect([ID],AllPrevious([Timestamp])))