Page 1 of 1

Increment Counter based on Stage Variable

Posted: Thu Sep 05, 2013 3:00 pm
by jweir
Hi all,

I am trying to increase a counter based on a record match. I first initialize the counter to 1. If there is a record match, I want to increase the counter by 1 else set the counter to 1.

For instance, if there are five records matches in a row, the counter would be equal to 5. Below is my code. Currently, the stage variable only increases to 2 and repeats 2 for every record match after that, so it is not increasing after 2. What is causing this?

Code: Select all

If svMatchCheck = 1 Then
(svGroupRecordIdx + 1)	
Else
(svGroupRecordIdx = 1)
I have also tried the below, which results in record matches returning only zero:

Code: Select all

If svMatchCheck = 1 Then
(svGroupRecordIdx = svGroupRecordIdx + 1)	
Else
(svGroupRecordIdx = 1)
Let me know if anyone needs more information.

Thanks in advance.

Posted: Thu Sep 05, 2013 5:03 pm
by ray.wurlod
The first code should work if it is the derivation expression for the stage variable svGroupRecordsIdx.

The second code will not work because you have tried to use an assignment statement, but it's actually treated as a Boolean test condition.

Posted: Fri Sep 06, 2013 10:59 am
by jweir
Thanks for the reply.

Not sure what your exact response was, since I am not a premium member. However, I believe to understand that we cannot use assignment statements within stage variables.

I will try and see if there is a workaround.

Posted: Fri Sep 06, 2013 3:07 pm
by chulett
A derivation is an expression who's derived value is automatically assigned to its associated variable. You cannot do direct assignments in any derivation.

Posted: Mon Sep 09, 2013 1:36 pm
by kiran0435
Use the given expression below. It will work.

If svMatchCheck = 1 Then
(svGroupRecordIdx + 1)
Else
1