Updated final answer, everything works like it should:
<br>
Group1
<br>
%%[
var @current, @previous
set @current = 0
set @previous = 1
set @fieldvalue = "1"
set @rows = LookupRows("UNEQUAL_TEST","GROUP", @fieldvalue)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowcount do
set @row = row(@rows,@i)
set @current = field(@row, "email")
output(concat("Start Iteration:",@i,"<br>"))
output(concat('BEFORE IF current:', v(@current), '; previous:', v(@previous),"<br>"))
if @current != @previous then
output(concat('NOT EQUAL current:', v(@current), '; previous:', v(@previous),"<br>"))
endif
set @previous = @current
output(concat("End Iteration:",@i,"<br><br>"))
next @i
endif
]%%
<br>
Group2
<br>
%%[
var @current, @previous
set @current = 0
set @previous = 1
set @fieldvalue = "2"
set @rows = LookupRows("UNEQUAL_TEST","GROUP", @fieldvalue)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowcount do
set @row = row(@rows,@i)
set @current = field(@row, "email")
output(concat("Start Iteration:",@i,"<br>"))
output(concat('BEFORE IF current:', v(@current), '; previous:', v(@previous),"<br>"))
if @current != @previous then
output(concat('NOT EQUAL current:', v(@current), '; previous:', v(@previous),"<br>"))
endif
set @previous = @current
output(concat("End Iteration:",@i,"<br><br>"))
next @i
endif
]%%
<br>
Group3
<br>
%%[
var @current, @previous
set @current = 0
set @previous = 1
set @fieldvalue = "3"
set @rows = LookupRows("UNEQUAL_TEST","GROUP", @fieldvalue)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowcount do
set @row = row(@rows,@i)
set @current = field(@row, "email")
output(concat("Start Iteration:",@i,"<br>"))
output(concat('BEFORE IF current:', v(@current), '; previous:', v(@previous),"<br>"))
if @current != @previous then
output(concat('NOT EQUAL current:', v(@current), '; previous:', v(@previous),"<br>"))
endif
set @previous = @current
output(concat("End Iteration:",@i,"<br><br>"))
next @i
endif
]%%
DataExtension UNEQUAL_TEST:
![Dataextension Unequal test](https://i.sstatic.net/ECJOB.png)
Output:
Group1
Start Iteration:1
BEFORE IF current:[email protected]; previous:1
NOT EQUAL current:[email protected]; previous:1
End Iteration:1
Start Iteration:2
BEFORE IF current:[email protected]; previous:[email protected]
End Iteration:2
Start Iteration:3
BEFORE IF current:[email protected]; previous:[email protected]
End Iteration:3
Group2
Start Iteration:1
BEFORE IF current:[email protected]; previous:1
NOT EQUAL current:[email protected]; previous:1
End Iteration:1
Start Iteration:2
BEFORE IF current:[email protected]; previous:[email protected]
End Iteration:2
Start Iteration:3
BEFORE IF current:[email protected]; previous:[email protected]
NOT EQUAL current:[email protected]; previous:[email protected]
End Iteration:3
Group3
Start Iteration:1
BEFORE IF current:[email protected]; previous:1
NOT EQUAL current:[email protected]; previous:1
End Iteration:1
Start Iteration:2
BEFORE IF current:[email protected]; previous:[email protected]
NOT EQUAL current:[email protected]; previous:[email protected]
End Iteration:2
Start Iteration:3
BEFORE IF current:[email protected]; previous:[email protected]
NOT EQUAL current:[email protected]; previous:[email protected]
End Iteration:3
end of final answer.
First answer:
Your code has some bad brackets. For example every output line needs to have two additional closing brackets.
My Script:
%%[
var @current, @previous
set @current = 0
set @previous = 1
set @fieldvalue = 999999
set @rows = LookupRows("DataExtension_Name","fieldname", @fieldvalue)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowcount do
set @row = row(@rows,@i)
set @current = field(@row, "otherOrSameFieldname")
if @current == @previous then
output(concat('EQUAL c:', v(@current), 'p:', v(@previous),"<br>"))
elseif @current != @previous then
output(concat('NOT EQUAL c:', v(@current), 'p:', v(@previous),"<br>"))
endif
set @previous = @current
next @i
endif
]%%
Output when all values of "otherOrSameField" would be the same (12345) and you get 4 rows with your LookUpRows function:
NOT EQUAL c:12345p:1
EQUAL c:12345p:12345
EQUAL c:12345p:12345
EQUAL c:12345p:12345
This is like you want it to be.
Output when all values "otherOrSameField" are different and you get 4 rows with your LookUpRows function:
NOT EQUAL c:12345p:1
NOT EQUAL c:23456p:12345
NOT EQUAL c:34567p:23456
NOT EQUAL c:45678p:34567
This is also the way you want it to be. I do not understand what you think does not work.