Here is the way I would handle this.
The Loc() function return a matrix of all of the values in the matrix that match the second argument in the Loc() function. Therefore
Give a matrix
[1,0,1,1,.,5]
then
Loc( [1,0,1,1,.,5], 1 )
would return the matrix
[ 1, 1, 1 ]
so it is a simple matter of counting the number of rows in the matrix to find the CountIF
Length( Loc( [1,0,1,1,.,5], 1 ) )
which will return the value 3
Here is the complete formula
If( Month( :A ) == Lag( Month( :A ) ),
.,
wMatrix = :W[Index( Row(), Row() + 29 )];
(Length( Loc( wMatrix, 1 ) ) * 100) / (Length( Loc( wMatrix, 1 ) ) + Length( Loc( wMatrix, 0 ) ));
)
Typically in JMP, one tries to avoid having calculation based upon a specific number of rows in the data table. This current Discussion is a good example of this. For the above formula to work correctly, the data table requires that exactly 30 rows are found after the change in month, to do the calculations on. We all know, that different months have different numbers of days. The following change to the above formula, shows how to do the calculations based upong finding all of the data for the current month, regardless of the number of days in the month
If( Month( :A ) == Lag( Month( :A ) ),
.,
wMatrix = :W[Current Data Table() << get rows where(
Year( :A ) == Year( :A[Row()] ) & Month( :A ) == Month( :A[Row()] )
)];
(Length( Loc( wMatrix, 1 ) ) * 100) / (Length( Loc( wMatrix, 1 ) ) + Length( Loc( wMatrix, 0 ) ));
)
Jim