Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex Selection Issue

Status
Not open for further replies.

MikeCopeland

Programmer
May 21, 2007
91
US
Using CR XI...
I have a very difficult selection situation: in my database there are record sets which can contain values of 28 and/or 36. I want to select the "28" data set if there _isn't_ a "36" data set, but I want to select the "36" data set if there is one. In the later case, there will be a "28" data set along with the "36" data set.
I have tried to use a "normalize formula" to convert the 36 value to 28 (and select only "28"s), but that fails because there's a "28" that's also selected.
Although I am printing the correct information - from the "36" data set - in the Grouped print line, the actual problem is that my Running Totals are wrong: that process is using the information from the "28" data set, not the "36". Here is an example of the way I'm developing the Running Totals:

// @countRelative - returns 1 for 13, 0 otherwise WhileReadingRecords;
if({CBSIntakeDischarge.LivingKey} = 13) then 1 else 0

Note that because I have _many_ of these functions (there are 21 different values I must total), this is the only way I know how to accumulate something I can Summarize in the Running Total. It appears that these functions (21 of them) are seeing the information from the "28" data set (and not the "36"), and are returning the 1 here - which is Summed in the (wrong) Running Total. And of course I have to use "WhileReadingRecords;" in all formulas, because the Running Total interface requires it... 8<{{
 
I'm not sure what you are summarizing or what the name of your 28/36 field is, but you could use a running total that does a distinctcount of some unique ID field, and then uses an evaluation formula like this:

{CBSIntakeDischarge.LivingKey} = 13 and
{table.28or36field} = maximum({table.28or36field},{table.groupfield})

This will return a value for the row in the group that contains the highest value--28 or 36. If there is no 36, then 28 is highest.

If this doesn't help, i think you should show some sample data.

-LB
 
Not a lot to go on without knowing what your data looks like.

Can you sort it so that it's grouped by whatever the major set is, then make the 28/36 field descending so the 36 will come first if there is one?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top