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

Formula do not calculate correctly

Status
Not open for further replies.

ancecb

Technical User
Sep 17, 2012
6
LV
Hi!

I'm using i-net Designer 11.2 for Crystal Report design.

I need sum, but seems like formula calculate fields without decimal part and on result it gives zero on decimal part. Could you help with this seems like I'm stuck? Maybe I need to use other formula.

-------------Formula I'm using now---
WhileReadingRecords;
NumberVar VAT0_Main_LC;
IF (({fld.Fld1} = "V_LC") AND ({fld.Fld8} = "0")) THEN VAT0_Main_LC:= VAT0_Main_LC + ToNumber({fld.Fld10});

-------------Data source-------------
Field1 | Field8 | Field10
V_LC | 0 | 71.94
V_LC | 0 | 341.22
V_LC | 0 | 0
V_LC | 21 | 4.13

-------------Result now-------------
412.00

-------------Result I need----------
413.16

 
Why are you using variables

Just use a formula

If {fld.Fld1} = "V_LC" AND {fld.Fld8} = "0" THEN ToNumber({fld.Fld10} else 0

You can then use a simple summary sum on this formula.

What result does that give you?

Ian
 
Removed too many brackets should be

If {fld.Fld1} = "V_LC" AND {fld.Fld8} = "0" THEN ToNumber({fld.Fld10}) else 0

Ian

 
Tested, nothing, it gave "0".

I don't think that there is enough with ... THEN ToNumber({fld.Fld10}), because on data file condition {fld.Fld1} = "V_LC" AND {fld.Fld8} = "0" repeats more than one time.

Any other idea?

 
I replaced parameters with values: If {fld.Fld1} = "V_LC" AND {fld.Fld8} = "0" THEN VAT0_Main_LC:=((71.94)+(341.22)+(0)) else 0;

And result was 413.16. That is correct. But how to force to get same result with paramaters from souce file.

 
Why are you still using a variable?

Please create a formula as I suggested and place this on report alongside your data.

If {fld.Fld1} = "V_LC" AND {fld.Fld8} = "0" THEN ToNumber({fld.Fld10}) else 0

What does the formula return?

Ian
 
Sorry, but I don't undarstand what you mean with "alongside your data".
 
I assume this data is in your details and returns

Field1 | Field8 | Field10
V_LC | 0 | 71.94
V_LC | 0 | 341.22
V_LC | 0 | 0
V_LC | 21 | 4.13

Place the formula in the details line too

Ian

 
Sorry, but I don't undarstand what is the purpose of this data changing. I need to figure out where is problem on tmpl and how to improve it, because data file is generated automatically and there isn't possible to achange anything in data file.
 
Your first post said

I need sum, but seems like formula calculate fields without decimal part and on result it gives zero on decimal part. Could you help with this seems like I'm stuck? Maybe I need to use other formula.

The formula I am suggesting will enable you to determine if its a crystal issue or a data issue.

I can not see your report so you need to tell us what is happening, if you do not want to do that then I can not help you.

Ian
 
I can not down load these files at work.

I am struggling to help you because I now do not know how you have identified problem if you have not created a crystal report from your data set.

All I want you to do is instead of using the formula you have currently placed on report add another formula as I have suggested and tell us what it returns.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top