Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use MAX() in a calculated field?
Message
 
 
To
25/01/2007 19:08:04
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Stonefield
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01189404
Message ID:
01189554
Views:
7
>>>max() and min() are always problematic in SQL - SELECT statements, because they have another meaning: the maximum value for a single field, within a set of grouped records.
>>>
>>>Replace it with an iif(), for example:
>>>
>>>
>>>iif(date_fld1 - date_fld2 > 0, date_fld1 - date_fld2, 0)
>>>
>>>
>>>... or create a UDF:
>>>
>>>
>>>MyMax(date_fld1 - date_fld2, 0)
>>>
>>
>>When trying your first suggestion (with IIF) I get no error but the numbers are (for some reason) so large that the report shows all asterisks. Even though the numbers should not be large at all (as I see the values in date_fld1 and date_fld2). I would prefer not to use the UDF approach as it may not be available when user runs this or that report. I will keep trying the variations of IIF to see how I can get it to work.
>>
>>Thank you very much for your help.
>
>You didn't accidentally multiply or divide, instead of subtracting?
>
>Also check the field width in the report, and the numeric format, e.g. "###" will show asterisks if you have four digits.

The problem is definitely with the IIF() and probably the way SFReports views it. I changed my IIF() expression to
IIF( DATE_FLD1 > DATE_FLD2, 1, 0 ) and I still see bunch of asterisks.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform