cancel
Showing results for 
Search instead for 
Did you mean: 

Formula - A number is required here

Former Member
0 Kudos

I am a novice with Crystal Reports. I have entered the formula below.

if {InsLine.LineAnnualizedPrem} >= '0' then Maximum ({InsCovTerm.CovTermVersion})

else 0

I am receiving an error when I test the formula. The error is "A number is required here' and the '0' is highlighted. The field is a numeric field (verified in browse field). What is causing this to error. I have the LineAnnualizedPrem as the 3rd sort in the report and it is ouput on the report. Any ideas on why it is requesting the number? Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

former_member260594
Active Contributor
0 Kudos

Darla,

Right click on Database Fields in the Field Explorer and check show field type. Then check that the field {InsCovTerm.CovTermVersion} is in fact a number. If it isn't you will need to use the tonumber function to convert it.

Former Member
0 Kudos

Both of the fields are numeric.

Former Member
0 Kudos

Hi..

Please use this

if {InsLine.LineAnnualizedPrem} >= 0 then

Maximum({InsCovTerm.CovTermVersion}) else 0

Regards,

Sastry

Former Member
0 Kudos

Sastry -

I tried what you requested and I am now receiving and error "A boolean is required here.'. It highlights the entire If and Else statement.

if {InsLine.LineAnnualizedPrem} >= 0 then

Maximum({InsCovTerm.CovTermVersion}) else 0

Former Member
0 Kudos

Hi Darla,

Please try this :

Numbervar x;

if not isnull({InsLine.LineAnnualizedPrem}) and {InsLine.LineAnnualizedPrem} >= 0 then

x:=tonumber(Maximum({InsCovTerm.CovTermVersion})) else

x:=0

Thanks,

Sastry

Former Member
0 Kudos

Sastry,

I am now receiving and error A number, current amount, boolean, date, time, date-time, or string is expected here. It is highlighting the 'x' prior to :=tonumber

{InsPolicy.PolExpDate} > DateTime (2008, 09, 01, 00, 00, 00) and

{Entities_BCO.EntLookup} = "enco" and

{CdPolLineType_LOB.CdPolLineTypeCode} in ["home", "rent"] and

if not isnull({InsLine.LineAnnualizedPrem}) and {InsLine.LineAnnualizedPrem} >= 0 then

x:=tonumber(Maximum({InsCovTerm.CovTermVersion})) else

x:=0

Former Member
0 Kudos

Hi...

Have you initilized 'x' like Numbervar x; . Also please copy and past the full formula which you are using

Regards,

Sastry

Former Member
0 Kudos

Sastry, How do you initialize the numbervar?

This is my entire record selection formula

{InsPolicy.PolExpDate} > DateTime (2008, 09, 01, 00, 00, 00) and

{Entities_BCO.EntLookup} = "enco" and

{CdPolLineType_LOB.CdPolLineTypeCode} in ["home", "rent"] and

Numbervar x;

if not isnull({InsLine.LineAnnualizedPrem}) and {InsLine.LineAnnualizedPrem} >= 0 then

x:=tonumber(Maximum({InsCovTerm.CovTermVersion})) else

x:=0

When i check the formula I receive a error "A boolean is required here.". It highlights the Numbervar x; line.

Thank you for your help!

Former Member
0 Kudos

Hi Darla..

When I reply in my previous post, I thought that this code you are using in a formula and not in record selection.

Darla, In Record Selection you can't use Maximum/Min/sum/ etc.(Aggregate functions).

So, please keep the following code in Record Selection.

{InsPolicy.PolExpDate} > DateTime (2008, 09, 01, 00, 00, 00) and

{Entities_BCO.EntLookup} = "enco" and

{CdPolLineType_LOB.CdPolLineTypeCode} in \"home\", \"rent\"

Now go in Formula fields and create a new formula and paste the following :

If not isnull({InsLine.LineAnnualizedPrem}) and {InsLine.LineAnnualizedPrem} >= 0 then

Maximum({InsCovTerm.CovTermVersion}) else 0

Then place this formula in your report and go in Section expert and write suppress condition

Hope this will help you.

Regards,

Sastry

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Darla,

If this field({InsLine.LineAnnualizedPrem} ) is a numeric field and if you are comparing it with the 0 values then u can remove the single quotes.

if {InsLine.LineAnnualizedPrem} >= 0 then Maximum{InsCovTerm.CovTermVersion}) else 0

Also the next field {InsCovTerm.CovTermVersion}should be a number other wise you need to convert it to numeric filed using the tonumber function.

I hope this helps you.

Regards,

Prashant

Former Member
0 Kudos

Both of the fields are numeric. When I remove the quotes I then receive this error - The remaining text does not appear to part of the formula. It highlights {InsCovTerm.CovTermVersion}) else 0.

if {InsLine.LineAnnualizedPrem} >= 0 then Maximum{InsCovTerm.CovTermVersion} else 0