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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nth most freq 1

Status
Not open for further replies.

lat4n6

Technical User
May 31, 2005
3
US
*Fairly new user*
How do I get the second most frequent if I don't want the first most frequent in certain instances??

I thought I could add this in the select expert,

if NthMostFrequent (1, {ITEMTYPE.Description}) = ["Clothing", "Other - Evidence"]
then NthMostFrequent (2, {ITEMTYPE.Description})

but I get an error message "The result of the selection must be boolean."

Suggestions on how to do this?

thanks
 
Change = to 'in'.

You might want to stick an else clause in there too.
 
Still getting: "The result of the selection must be boolean."

other suggestions?

thanks
 
Your post is a bit strange. It sounds like you're putting the code in your selection criteria, but I'm pretty certain NthMostFrequent cannot be validated at this stage. It's used for formulas.

The other thing is that piece of code on it's own will not return a boolean error. Can you either post your entire seletion criteria or formula where this code is taken from? Also, are you getting this error when you try to save the formula, or when you are executing the report? Where is the cursor placed when the error is returned?

Naith
 
I WAS trying to add it as a formula in the selection criteria and was getting the error at the * when I tried to save it.

{LABEXAM.Section} = "CRIM" and
trim({LABEXAM.Report Format}) = "NONBIO" and
{@backlog} > 30.00 and *
if NthMostFrequent (1, {ITEMTYPE.Description}) = ["Clothing", "Other - Evidence"]
then NthMostFrequent (2, {ITEMTYPE.Description})

I did also try creating a new formula in the formula field:
if NthMostFrequent (1, {ITEMTYPE.Description}) in ["Clothing", "Other - Evidence"]
then NthMostFrequent (2, {ITEMTYPE.Description})
else NthMostFrequent (1, {ITEMTYPE.Description})
However, it then gave me the same description for everything (and shouldn't have).

I'm a new user and must be missing something.
Thanks again.


 
If you use nthmostfrequent(1,{itemtype.description}) you are asking for the most frequent description in the entire report, and therefore only one description will be returned. Also you cannot use nthmostfrequent in the record selection formula, since it is evaluated on a later pass.

If you mean to evaluate the most frequent within a group, you can go to report->selection formula->GROUP and enter:

if nthmostfrequent(1,{itemtype.description},{table.group}) in ["Clothing", "Other - Evidence"] then
{itemtype.description} = nthmostfrequent(2,{itemtype.description}) else
{itemtype.description} = nthmostfrequent(1,{itemtype.description})

-LB
 
Actually, that formula should be:

if nthmostfrequent(1,{itemtype.description},{table.group}) in ["Clothing", "Other - Evidence"] then
{itemtype.description} = nthmostfrequent(2,{itemtype.description},{table.group}) else
{itemtype.description} = nthmostfrequent(1,{itemtype.description},{table.group})

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top