Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to consider all rows before an active row?

sarajavedsani
5 - Atom

Hello,

 

I am trying to count the number of instances a value recurs by looking into all the rows that came before this active row. 

 

For example 

Row  Amount Count of occurrences (expected output)
1                              (0.43)1
2                   253,317.761
3                   120,445.161
4                              60.901
5                                0.431
6                   (86,272.00)1
7                   (31,920.52)1
8                 (395,127.53)1
9                   (26,766.62)1
10             (2,073,374.98)1
11                 (858,246.33)1
12                      (5,109.58)1
13                         (664.15)1
14                      (6,035.00)1
15                      (6,300.00)1
16                      (5,880.00)1
17                              (0.43)2
18                                0.432
19                              (0.43)3

 

 

 

For example, in table above row 5 is showing that 0.43 has 1 count when considering all rows before and in row 18 the count will change to 2 as now there are 2 instances of 0.43 while considering all rows before row 18.

 

In excel the formula I use is COUNTIF(J$1:J2,J2) however not sure how to do this in Alteryx. 

 

Appreciate any help I can get on this. Thank you.

 

2 REPLIES 2
ed_hayter
12 - Quasar

I have used a multi-row formula grouped by value and then said look at the previous occurrence of a value and add one to its running count from before. If it is the first occurrence set the running count to 1.

 

image.png  The formula just cleans the negative numbers indicated by brackets into negative numbers but the multi-row could be applied to the string values and the same result would be attained if you dont want to change that

sarajavedsani
5 - Atom

Thank you! This worked wonders!

Labels
Top Solution Authors