- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to directly calculate the number of consecutive conditions?
For example, take "height" as an example and count the consecutive number of "height"s in the row greater than the "height" in the previous row.
I added an auxiliary column h to determine whether the "height" of the row is greater than the "height" of the previous row, and then counted the consecutive "height" of the row greater than the "height" of the previous row in the other column.If the "height" is less than the "height" of the previous row have to recalculate.
How can do this calculation in one step?
I tried this, but it didn't work:
if(:height>Lag(:height,1),row()-Contains(:height[Index(1,Row())],:height<Lag(:height,1),-1))
- Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to directly calculate the number of consecutive conditions?
Looks like second If had a single = for assignment instead of a == for equivalence test.
If( Row() == 1,
hCounter = 0,
If(
Lag( :name ) == :name,
If( :age > Lag( :age, 1 ),
Empty()
),
hCounter++, hCounter = 0
)
);
If( hCounter == 0,
.,
hCounter
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to directly calculate the number of consecutive conditions?
Hi John,
I see the error but this does not provide the calculation and checks I require. My last post shows a new data table and formula that is close.
Thank you
Onjai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to directly calculate the number of consecutive conditions?
Hi everyone,
It took me awhile but I eventually figured out how to add a value to the previous row if the condition was true.
So I want to share this with you. I am using this to tag sequential values within groups.
Thank you all.
Cheers!
If( Row() == 1,
.,
If( :master == Lag( :master ),
If( :roll - Lag( :roll ) == 1,
:seq. rolls v3[Row() - 1] = 1,
.
)
)
)
- « Previous
-
- 1
- 2
- Next »