MikeCopeland
Programmer
Using CRXI...
Nothing I'e yet tried has solved this problem, so I'm trying a new function. The problem is that I need to scan sets of rows to see if a certain value exists in one of them. If so, I want the return a value from that row; if none of the rows has the value, I want to return a default (string) value - always to a Group line.
Here is some data that illustrates the problem:
ID CKey PK Date
809549 213298 44 8/15/2007
813644 213298 47 9/9/2007
813825 213298 40 9/9/2007
814610 213298 30 8/15/2007
816644 213298 30 9/20/2007
817681 213298 40 10/7/2007
822866 213298 40 11/9/2007
828117 213298 47 12/9/2007
829863 213298 42 12/26/2007
828859 213502 43 12/20/2007
830785 213502 40 1/7/2008
832998 213502 48 1/18/2008
833000 213502 47 1/18/2008
In the first dataset, there is a row with the value of 42 in the "PK" column - I want to detect that and return the "Date" value. In the 2nd dataset, there is no row having 42, and I want to return "Open". Here is the formula I'm trying (which fails, of course):
// disDate - returns the Client's discharge date or "Open"
global NumberVar clientKey = 0;
global NumberVar bFound42 = 0;
if({ClientPacket.CKey} <> clientKey) then
( // initialize variable for new data set
clientKey = {ClientPacket.PK};
bFound42 = 0;
"Open";
)
else
(
if({ClientPacket.PK} = 42) then
(
bFound42 = 1;
toText({ClientPacket.Date}, "mm/dd/yyyy");
)
)
I suspect there are fundamental issues here, but try as I might, I'm unable to adjust this to achieve my goal. Please advise. TIA
Nothing I'e yet tried has solved this problem, so I'm trying a new function. The problem is that I need to scan sets of rows to see if a certain value exists in one of them. If so, I want the return a value from that row; if none of the rows has the value, I want to return a default (string) value - always to a Group line.
Here is some data that illustrates the problem:
ID CKey PK Date
809549 213298 44 8/15/2007
813644 213298 47 9/9/2007
813825 213298 40 9/9/2007
814610 213298 30 8/15/2007
816644 213298 30 9/20/2007
817681 213298 40 10/7/2007
822866 213298 40 11/9/2007
828117 213298 47 12/9/2007
829863 213298 42 12/26/2007
828859 213502 43 12/20/2007
830785 213502 40 1/7/2008
832998 213502 48 1/18/2008
833000 213502 47 1/18/2008
In the first dataset, there is a row with the value of 42 in the "PK" column - I want to detect that and return the "Date" value. In the 2nd dataset, there is no row having 42, and I want to return "Open". Here is the formula I'm trying (which fails, of course):
// disDate - returns the Client's discharge date or "Open"
global NumberVar clientKey = 0;
global NumberVar bFound42 = 0;
if({ClientPacket.CKey} <> clientKey) then
( // initialize variable for new data set
clientKey = {ClientPacket.PK};
bFound42 = 0;
"Open";
)
else
(
if({ClientPacket.PK} = 42) then
(
bFound42 = 1;
toText({ClientPacket.Date}, "mm/dd/yyyy");
)
)
I suspect there are fundamental issues here, but try as I might, I'm unable to adjust this to achieve my goal. Please advise. TIA