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

Help with a Boolan error when fields are a string

Status
Not open for further replies.

hlb6

Technical User
Aug 2, 2013
27
US
Ok - I am getting frustrated with this. In my group footer ({Command.usr_id}) I have to group together the names and sum each of there columns if my parameter = No and they have more thatn one listing. ie.:
Doe 0 12 15 31
Smith 5 6 27 4
Mouse 0 0 0 5
Doe 5 20 0 0 I need Doe to group and sum his colums

Doe 5 32 15 31
Smith 5 6 27 4
Mouse 0 20 0 0

I am putting my formula in the group footer: On the SUM of the field I get a "Boolan is required here"; these fields are strings - Please help me to understand why and how to fix this -

WhilePrintingRecords;
If ({?p_Department}) = "Yes" then {?p_Excel}
else
(If (Count({Command.usr_id}))>1 then
Sum ({@BATSV}, {Command.usr_id})and
Sum ({@BERV}, {Command.usr_id}) and
Sum ({@BML}, {Command.usr_id}) and
Sum ({@BLUE}, {Command.usr_id}) and
Sum ({@DEMO}, {Command.usr_id}) and
Sum ({@FL}, {Command.usr_id}) and
Sum ({@HL}, {Command.usr_id}) and
Sum ({@HOLI}, {Command.usr_id})) and
Sum ({@INJRY}, {Command.usr_id}) and
Sum ({@JURY}, {Command.usr_id}) and
Sum ({@LTR HL}, {Command.usr_id}) and
Sum ({@M RENT}, {Command.usr_id}) and
Sum ({@NEW E}, {Command.usr_id}) and
Sum ({@AFA}, {Command.usr_id}) and
Sum ({@NPL}, {Command.usr_id}) and
Sum ({@PM}, {Command.usr_id}) and
Sum ({@PL}, {Command.usr_id}) and
Sum ({@PRT DR}, {Command.usr_id}) and
Sum ({@PERSL}, {Command.usr_id}) and
Sum ({@RECAP}, {Command.usr_id}) and
Sum ({@RESTK}, {Command.usr_id}) and
Sum ({@SFTY}, {Command.usr_id}) and
Sum ({@SALES}, {Command.usr_id}) and
Sum ({@ST}, {Command.usr_id}) and
Sum ({@SL}, {Command.usr_id}) and
Sum ({@SHOP M}, {Command.usr_id}) and
Sum ({@S TRNG}, {Command.usr_id}) and
Sum ({@SICK}, {Command.usr_id}) and
Sum ({@SPS}, {Command.usr_id}) and
Sum ({@STR HL}, {Command.usr_id}) and
Sum ({@SUP}, {Command.usr_id}) and
Sum ({@TIRE P}, {Command.usr_id}) and
Sum ({@TL SUP}, {Command.usr_id}) and
Sum ({@TRN}, {Command.usr_id}) and
Sum ({@USED E}, {Command.usr_id}) and
Sum ({@UTLTY}, {Command.usr_id}) and
Sum ({@VAC}, {Command.usr_id}) and
Sum ({@TotHours}, {Command.usr_id});
 
The second part of your If-Then-Else statement (ie, the Else) returns a number, so the first part (ie, the Then) must also be numeric, ie {?p_Excel}.

Alternatively, if {?p_Excel} is a string you could convert the result of the Else statement to text using the ToText function.

If the parameter {?p_Excel} is neither numeric or a string you will need to provide more detail.

Pete
 
Pete-

I am only modifing someone esles work - yes the {?p_Excel} is a Boolean. Now I understand the why - how do if fix this - do I make the {?p_Excel} a string? I have tried to change the second part (the IF) to boolean but then I get a string error.
 
Is it possible that I am placing the formula in the wrong place; ie.: Group#4 Name:Command.usr_id - I am placing it in the footer of this group. I just saw that when using the Selection Expert and placing the formula there (the Suppress formula editor) it has to have a Boolen Result. If this is true, then where or how do I use my formula to get the results that I am seeking?

From: "Are you creating a (record) selection formula?

There are several formulas that expect boolean results, such as suppression formulas or selection formulas. There are more, but that should be all that matters for now.

If you want to filter the result set that the DB returns, then you will return True if you want to display it, and False if you don't.

You wouldn't be able to use a record selection formula for all three conditions because the third condition requires you to display all records.
 
I have taken another look at this and to be honest your post doesn't make any sense to me.

I would be surprised if the formula from your original post will achieve what you need, but without understanding what you are trying to do I am not sure there is much I can offer.

I can tell you there are multiple issues with your formula though; mixed data type results of your If-Then-Else (Boolean and Numeric) and the use of 'and' in the latter part of your formula. Assuming you are trying to add the amounts you need to use "+" not "and".

You can probably get Crystal to accept the syntax of your formula by converting everything to text and replacing the "+" with "and" but as I said, I suspect that isn't going to help you. It would look something ike this:
Code:
If 	({?p_Department}) = "Yes" 
Then 	ToText({?p_Excel}) 
Else 
If 	Count({Comm+.usr_id}) > 1 
Then	ToText	(
		Sum ({@BATSV}, {Comm+.usr_id})+ 
		Sum ({@BERV}, {Comm+.usr_id}) +
		Sum ({@BML}, {Comm+.usr_id}) +
		Sum ({@BLUE}, {Comm+.usr_id}) +
		Sum ({@DEMO}, {Comm+.usr_id}) +
		Sum ({@FL}, {Comm+.usr_id}) +
		Sum ({@HL}, {Comm+.usr_id}) +
		Sum ({@HOLI}, {Comm+.usr_id})) + 
		Sum ({@INJRY}, {Comm+.usr_id}) +
		Sum ({@JURY}, {Comm+.usr_id}) + 
		Sum ({@LTR HL}, {Comm+.usr_id}) +
		Sum ({@M RENT}, {Comm+.usr_id}) +
		Sum ({@NEW E}, {Comm+.usr_id}) +
		Sum ({@AFA}, {Comm+.usr_id}) +
		Sum ({@NPL}, {Comm+.usr_id}) +
		Sum ({@PM}, {Comm+.usr_id}) +
		Sum ({@PL}, {Comm+.usr_id}) +
		Sum ({@PRT DR}, {Comm+.usr_id}) +
		Sum ({@PERSL}, {Comm+.usr_id}) +
		Sum ({@RECAP}, {Comm+.usr_id}) +
		Sum ({@RESTK}, {Comm+.usr_id}) +
		Sum ({@SFTY}, {Comm+.usr_id}) +
		Sum ({@SALES}, {Comm+.usr_id}) +
		Sum ({@ST}, {Comm+.usr_id}) +
		Sum ({@SL}, {Comm+.usr_id}) +
		Sum ({@SHOP M}, {Comm+.usr_id}) + 
		Sum ({@S TRNG}, {Comm+.usr_id}) +
		Sum ({@SICK}, {Comm+.usr_id}) +
		Sum ({@SPS}, {Comm+.usr_id}) +
		Sum ({@STR HL}, {Comm+.usr_id}) +
		Sum ({@SUP}, {Comm+.usr_id}) +
		Sum ({@TIRE P}, {Comm+.usr_id}) +
		Sum ({@TL SUP}, {Comm+.usr_id}) +
		Sum ({@TRN}, {Comm+.usr_id}) +
		Sum ({@USED E}, {Comm+.usr_id}) +
		Sum ({@UTLTY}, {Comm+.usr_id}) +
		Sum ({@VAC}, {Comm+.usr_id}) +
		Sum ({@TotHours}, {Comm+.usr_id})
		)

Beyond that I don't have much else to offer, unless you can explain (with sample data) what you have and where you are trying to get to.

Pete



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top