strange behavior of the sum function

Stimulsoft Ultimate discussion
Post Reply
mirmidone
Posts: 15
Joined: Thu Mar 29, 2012 8:55 am

strange behavior of the sum function

Post by mirmidone »

in my report I insert a total textbox (in footer band) which contains this code:

{Sum(Switch(SourceData1.NAME != "" & SourceData1.NAME1== "" & SourceData1.NAME2 == "",SourceData1.AMOUNT,
SourceData1.NAME != "" & SourceData1.NAME1 != "" & SourceData1.NAME2 == "",SourceData1.AMOUNT/2,
SourceData1.NAME != "" & SourceData1.NAME1 != "" & SourceData1.NAME2 != "",SourceData1.AMOUNT/3))}

(the code Sum the division the amount by the number of users. If they are two users, divide by two, if they are three users, divide by three, if only one user does not divide).

But the result of the sum is often not good.
Why this ?
Is there another way to make this sum ?

Many Thanks for help
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: strange behavior of the sum function

Post by Edward »

Hi Mirmidone,

Please try to use Calculated Columns to calculate the values per row, and then you could get a sum of them.
https://www.youtube.com/watch?v=9yN3IRTP_aI

In this case, in the report, you will be able to see the problem with calculation, if any. Also please check that SourceData1.AMOUNT is not equals DBNull.Value, in that case, you could use something like that:

Code: Select all

SourceData1["AMOUNT"] is DBNull ? 0 : SourceData1.AMOUNT 
Thank you,
Edward
Post Reply