This is a migrated thread and some comments may be shown as answers.

bad calculation?

1 Answer 74 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 23 Feb 2011, 02:18 PM
Hi guys,

I think i've found something strange:

If I put on a report with a simple group a textbox field on the group header or group footer with this formula on value property:

=(sum(dbfield1)/2000)*100

the results differs from this formula that must be the same:

=(sum(dbfield1)*100)/2000

It is, as I see,  because if result of sum(dbfield1)/2000 is 0 <= x <1 telerik reporting uses 0 to continue with the formula.

For example:

Dbfield1=5

Formula1: =(sum(dbfield1)/2000)*100 = (5/2000)*100 = 0.0025*100 At this point Telerik reporting uses 0 not 0.0025 so 0*100=0

Formula2: =(sum(dbfield1)*100)/2000 = (5*100)/2000 = 500/2000 = 0.25

Is this behavior correct?

Thanks

David


1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 25 Feb 2011, 01:30 PM
Hi David,

We've noticed that you divide integers and this will lead to an integer result. This is a standard .net behavior, and an easy solution would be to cast your data to double data type with CDbl(System.Object) integrated Function.
=CDbl(Sum(dbfield1) / CDbl(2000*100)

Greetings,
Peter
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or