Board index » delphi » if AVERAGE is 0 then TQRExpression return NULL

if AVERAGE is 0 then TQRExpression return NULL


2004-06-02 07:09:13 PM
delphi258
Hi there,
I am calculating avarages on my QReport with QRExpressions. Unfortunately,
sometimes these averages are 0. In this case, the expression does not return
0 but nothing. Is it possible to change the expression so a 0 would be shown
if AVERAGE(memTabelle.1_ANZ_PRM1_ANW1) is 0??
Thanks,
Pascal
 
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Pascal Schmidt-Volkmar writes:
Quote
Hi there,

I am calculating avarages on my QReport with QRExpressions. Unfortunately,
sometimes these averages are 0. In this case, the expression does not return
0 but nothing. Is it possible to change the expression so a 0 would be shown
if AVERAGE(memTabelle.1_ANZ_PRM1_ANW1) is 0??

Thanks,

Pascal


Pascal,
is there a mask on this particular QRExpression? if so, you could set it
to print 0 even when the result is null.
HTH.
---
Dhaval Shah
Sr. Software Developer
Perth, Australia
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Hi Dhaval,
I tried to set the mask to "##0" but unfortunately with no effect....
Greetings,
Pascal
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Pascal Schmidt-Volkmar writes:
Quote
Hi Dhaval,

I tried to set the mask to "##0" but unfortunately with no effect....

Greetings,

Pascal


Pascal,
that's no good hey !!
try this (cut and paste as your expression) and try running the report.
IF(AVERAGE(memTabelle.1_ANZ_PRM1_ANW1) Not
NULL,AVERAGE(memTabelle.1_ANZ_PRM1_ANW1),0)
Let me know how you go.
cheers
---
Dhaval Shah
Sr. Software Developer
Perth, Australia
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Dhaval,
I tried that and I do get this error when I click on "check": "Error: wrong
arguments for IF".
:(
Pascal
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Dhaval,
the problem seems to be as if "Null" does not exist in the expression
builder. Using it throws the error that the function is unknown!!
How could Null be exchanged??
Pascal
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Pascal Schmidt-Volkmar writes:
Quote
Dhaval,

I tried that and I do get this error when I click on "check": "Error: wrong
arguments for IF".

:(

Pascal


Pascal,
try not clicking on "check" and just running the report. Also, make sure
your uses include "variants" unit.
let's see how this goes.
cheers
---
Dhaval Shah
Sr. Software Developer
Perth, Australia
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Dhavel,
first of all, thanks a lot for your time helping me!!
Now, after including Variants, I do get "Wrong" in my expression field.....
Funny, uhm???!!! Before the field was blank....
Pascal
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Pascal Schmidt-Volkmar writes:
Quote
Dhavel,

first of all, thanks a lot for your time helping me!!

Now, after including Variants, I do get "Wrong" in my expression field.....
Funny, uhm???!!! Before the field was blank....

Pascal


Hi Pascal,
what do you mean by "wrong" there? please post a sample of your data
and output here.
My initial thought is, this might be clashing with the mask you've
provided. Could you also check this after removing the masks, if any.
cheers
---
Dhaval Shah
Sr. Software Developer
Perth, Australia
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Dhavel,
I meant with "wrong" that displaying that report, the value shown is really
the word "wrong".....
I removed all masks for that field, but the wrong still occurs.... If you
would provide me with a mail address I could send you a screenshot.
Unfortunately my project needs a huge database to work so posting an example
would be complicated...
Greetz,
Pascal
 

Re:if AVERAGE is 0 then TQRExpression return NULL

Pascal Schmidt-Volkmar writes:
Quote
Dhavel,

I meant with "wrong" that displaying that report, the value shown is really
the word "wrong".....

I removed all masks for that field, but the wrong still occurs.... If you
would provide me with a mail address I could send you a screenshot.

Unfortunately my project needs a huge database to work so posting an example
would be complicated...

Greetz,

Pascal


Pascal,
Is it possible to shred down the database to just a few records that'd
give a better idea when tested? if so, zip your project and send it
across with the database (which are you using?). I am sure we're missing
something trivial here (or maybe something "unthinkable" ;-) )
My email is the XXXX@XXXXX.COM
cheers
--
---
Dhaval Shah
Sr. Software Developer
Perth, Australia