Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

General Discussions

Discuss any topics that are not product-specific here.

How to identify consecutive values?

Jenis
5 - Atom

Hi,

I want to identify when the product column has 3 consecutive values or more. If the values is less than 3 consecutive values then the output should be false . I'm not sure how to get this type of output. Any help will be appreciated.

 

IDProductMax_ConsecOutput
10113Consecutive
10123Consecutive
10133Consecutive
10113FALSE
10123FALSE
10215FALSE
10215FALSE
10215FALSE
10215Consecutive
10225Consecutive
10235Consecutive
10245Consecutive
10255Consecutive
10314Consecutive
10324Consecutive
10334Consecutive
10344Consecutive
10314Consecutive
10324Consecutive
10334Consecutive
10 REPLIES 10
ShankerV
17 - Castor

Hi @Jenis 

 

You can do this with the help of multi row formula.

 

Many thanks

Shanker V

damalraj22
Alteryx
Alteryx

Hi, 

 

You will want to use the multi row formula to do this as Shanker said. Below I have a formula that I think should work. Let me know if you have any questions. 

 

IF [Row+1:ID]=ID and [Row+2:ID]=ID
THEN "Consecutive"
ELSE "False"
ENDIF

TimN
13 - Pulsar

Hi,

Something like this?

 

 

Jenis
5 - Atom

Hi @shankerV

Yes, I tried this but its not giving me that output.

 

If ([Product]-1 =[Row-1:Product] and [Product]+1 =[Row+1:Product]) Then “Consecutive” Else “False” Endif

damalraj22
Alteryx
Alteryx

Hi, 

 

Try using the formula below: 

 

IF ([Row+1:Product]=Product+1 and [Row+2:Product]=Product+2)
OR ([Row-1:Product]=Product-1 and [Row-2:Product]=Product-2)
THEN "Consecutive"
ELSE "False"
ENDIF

Jenis
5 - Atom

Hi @damalraj22

Thanks for your response. When I applied your formula to my larger dataset, it worked exactly in most cases apart from this case. In ID-104, in the 6th row, Instead of giving consecutive, its giving false.

 

IDProductMax_ConsecOutput
10413FALSE
10413FALSE
10423FALSE
10413FALSE
10413Consecutive
10423FALSE
10433Consecutive
10413FALSE
10423FALSE

 

 

ShankerV
17 - Castor

Hi @Jenis 

 

Hope you are having a good day!!!

 

Please find the solution for you using the same Multi Row formula.

You can apply this for any huge set of data, will give you the expected output.

ShankerV_0-1670655593274.png

 

 

Have myself tried with some huge dataset, please find the result below.

ShankerV_0-1670655896181.png

 

Hope your issue is resolved. Feel free to mark helpful answers as a solution, so that future users with the same issue can find them easier!!!!

 

Many thanks

Shanker V

 

ShankerV
17 - Castor

Hi  @Jenis 

 

Could you please check and confirm whether it worked.

 

If yes, please like this post and mark it as a solution. If you have any other questions, please let us know.

 

Many thanks

Shanker V

damalraj22
Alteryx
Alteryx

Got it, you might need to add another statement in your formula command. Let me know if the formula below works.

 

IF ([Row+1:Product]=Product+1 and [Row+2:Product]=Product+2)
OR ([Row-1:Product]=Product-1 and [Row-2:Product]=Product-2)

OR ( ([Row+1:Product]=Product+1 and  ([Row-1:Product]=Product-1)
THEN "Consecutive"
ELSE "False"
ENDIF

Labels