Author |
Message |
fabrizio
Newbie
Joined: 10 Dec 2012
Online Status: Offline
Posts: 15
|
 Topic: if help Posted: 10 Dec 2012 at 1:38am |
Hi guys !!!! Im a new member!!!! I have never used crystal reports 2008 before but my boss asked me to learn it as soon as possible  . I have a problem with IF formula (Basic Syntax): if "J10B" in {VR_CLASSIFICA_PS.ID_ATT_ORIG} and {#countCapre}>0 then formula = 0 elseIf "J09B" in {VR_CLASSIFICA_PS.ID_ATT_ORIG} And {#countePecore}>0 THEN formula = 0 elseif "J11"in{VR_CLASSIFICA_PS.ID_ATT_ORIG} and {#countScrofe}>0 then formula = 0 elseif "J02" in {VR_CLASSIFICA_PS.ID_ATT_ORIG} and ({#nr_Vitellini}<={#nrVacche}) then formula = 0 elseif "J02" in {VR_CLASSIFICA_PS.ID_ATT_ORIG} and ({#nr_Vitellini}>{#nrVacche}) then formula = ({#nr_Vitellini}-{#nrVacche})*{VR_CLASSIFICA_PS.PS} else formula ={VR_CLASSIFICA_PS.PS_AGG_NO_P} end if the program tells me the formula is correct but I don't get back any result but just blank cell. Please help me !!!!!!!!!!!!!!!!!
|
IP Logged |
|
comatt1
Senior Member
Joined: 19 May 2011
Online Status: Offline
Posts: 337
|
 Posted: 10 Dec 2012 at 4:18am |
"J10B" in {VR_CLASSIFICA_PS.ID_ATT_ORIG}
I believe you have reversed logic. You dont need to use 'in' here.
IF {VR_CLASSIFICA_PS.ID_ATT_ORIG} like "*J10B*" ....
also you don't have to assign a value to anything. Just say
IF {FIELD} like 'BLAH' then
0
else
1
.... If you try this with Crystal Syntax I think it will work
if ({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J10B*' and {#countCapre}>0) or
({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J09B*' And {#countePecore}>0) or
({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J11*' and {#countScrofe}>0) or
({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J02*' and ({#nr_Vitellini}<={#nrVacche}))
then
0
else
if {VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J02*' and ({#nr_Vitellini}>{#nrVacche}) then
({#nr_Vitellini}-{#nrVacche})*{VR_CLASSIFICA_PS.PS}
else
{VR_CLASSIFICA_PS.PS_AGG_NO_P}
Edited by comatt1 - 10 Dec 2012 at 4:26am
|
IP Logged |
|
fabrizio
Newbie
Joined: 10 Dec 2012
Online Status: Offline
Posts: 15
|
 Posted: 10 Dec 2012 at 4:28am |
First thanks for your help  I tried in this way but doesn't work, maybe I have a problem with subtotals !!!! if {VR_CLASSIFICA_PS.ID_ATT_ORIG} like "*J10B*" and {#countCapre}>0 then formula = 0 elseIf {VR_CLASSIFICA_PS.ID_ATT_ORIG} like "*J09B*" And {#countePecore}>0 THEN formula = 0 elseif {VR_CLASSIFICA_PS.ID_ATT_ORIG} like "*J11*" and {#countScrofe}>0 then formula = 0 elseif {VR_CLASSIFICA_PS.ID_ATT_ORIG} like "*J02*" and ({#nr_Vitellini}<={#nrVacche}) then formula = 0 elseif {VR_CLASSIFICA_PS.ID_ATT_ORIG} like "*J02*" and ({#nr_Vitellini}>{#nrVacche}) then formula = ({#nr_Vitellini}-{#nrVacche})*{VR_CLASSIFICA_PS.PS} else formula ={VR_CLASSIFICA_PS.PS_AGG_NO_P} end if
Edited by fabrizio - 10 Dec 2012 at 4:31am
|
IP Logged |
|
fabrizio
Newbie
Joined: 10 Dec 2012
Online Status: Offline
Posts: 15
|
 Posted: 11 Dec 2012 at 3:13am |
I tried it but it doesn't work I think because the program didn't read the subtotals in this way I have a null values. I haven't any idea to resolve this problem
|
IP Logged |
|
comatt1
Senior Member
Joined: 19 May 2011
Online Status: Offline
Posts: 337
|
 Posted: 11 Dec 2012 at 6:14am |
check the null handling within the report, on File (toolbar), Options -> Reporting (tab). Make sure 'Convert Database null to default' and 'Other nulls to default' are checked.
Then within the formula you can set 'Defaults for Nulls' instead of 'Exceptions for Nulls'.
Try this.
|
IP Logged |
|
fabrizio
Newbie
Joined: 10 Dec 2012
Online Status: Offline
Posts: 15
|
 Posted: 12 Dec 2012 at 12:01am |
I tried it and now the formula works but I have just one problem it doesn 't read one subtotal {#nrVacche} if {VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J02*' and ({#nr_Vitellini}>{#nrVacche}) then ({#nr_Vitellini}-{#nrVacche})*{VR_CLASSIFICA_PS.PS} else if ({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J10B*' and {#countCapre}>0) or ({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J09B*' And {#countePecore}>0) or ({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J11*' and {#countScrofe}>0) or ({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J02*' and ({#nr_Vitellini}<={#nrVacche})) then 0 else {VR_CLASSIFICA_PS.PS_AGG_NO_P} the formula can't read that (red text) I don't know why !!!! Thanks you are very helpful
|
IP Logged |
|
comatt1
Senior Member
Joined: 19 May 2011
Online Status: Offline
Posts: 337
|
 Posted: 12 Dec 2012 at 2:27am |
I am not too confident I can help any further with that particular area of code.
Is this for a farm or something?
|
IP Logged |
|
fabrizio
Newbie
Joined: 10 Dec 2012
Online Status: Offline
Posts: 15
|
 Posted: 12 Dec 2012 at 3:14am |
yes this is a farm #nr_Vitellini=sum of VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J02* #nrVacche=sum of VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J07*' and '*J08*'
|
IP Logged |
|
comatt1
Senior Member
Joined: 19 May 2011
Online Status: Offline
Posts: 337
|
 Posted: 12 Dec 2012 at 3:20am |
That may have answered my question. If you are working with the evaluate of the running total, what is the EXACT logic in that formula?
sum of VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J07*' and '*J08*' -- would be incorrect
{VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J07*' or {VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J08*' ----
would be the correct logic assuming we are on same page.
My assumptions are that there can only be one 'J' code per record, so and would ALWAYS fail if the logic you posted was in the evaluate section.
Edited by comatt1 - 12 Dec 2012 at 3:21am
|
IP Logged |
|
fabrizio
Newbie
Joined: 10 Dec 2012
Online Status: Offline
Posts: 15
|
 Posted: 12 Dec 2012 at 4:43am |
Local numberVar x :=x ; Local numberVar y :=y ; x :=sum({VR_CLASSIFICA_PS.Dimensione},{VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J02*'); y :=sum({VR_CLASSIFICA_PS.Dimensione},{VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J07*' or {VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J08*'); if ({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J10B*' and {#countCapre}>0) or ({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J09B*' And {#countePecore}>0) or ({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J11*' and {#countScrofe}>0) or ({VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J02*' and (x<=y)) then 0 else if {VR_CLASSIFICA_PS.ID_ATT_ORIG} like '*J02*' and x>y then (x-y)*{VR_CLASSIFICA_PS.PS} else {VR_CLASSIFICA_PS.PS_AGG_NO_P} focus on the red text: I'm sure is not correct the assignments but I would like to calculate the sum of dimension for ID.activities=J02 etc etc
|
IP Logged |
|
|