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

Sum function not working

4 Answers 225 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
seth
Top achievements
Rank 1
seth asked on 05 Jul 2017, 03:09 PM

Hi I have some Issues with an expression that should be working but its instead outputting an empty result and I'm sure it should be working because it actually works for 1 of the 4 tables I'm printing on the report but not for the other 3.

the expression is the following: 

=IIf(Fields.BankMovementType = "TRANSFER", Exec("table1",Sum(NetPayment)),"")

which makes use of this calculated field:

NetPayment (Double) =IIf(Fields.BankMovementType = "TRANSFER", (Fields.Perception -  Fields.Deduction),0)

this actually gives me a sumatory of the NetPayment for all the "TRANSFER" movement types and leaves out the rest of the movement types, now I have tested this Expression multiple times and it works perfectly, however it only seems to be calculating for the "TRANSFER" movement type, in one table only. 

the other tables for the different forms of payment use the exact same formula, the only thing that changes is the condition:

=IIf(Fields.BankMovementType = "EFFECTIVE", Exec("table5",Sum(NetPayment)),"")

NetPayment (Double)  =IIf(Fields.BankMovementType = "EFFECTIVE", (Fields.Perception -  Fields.Deduction),0)

however this time around the field that is supposed to contain the sumatory is completely empty and I simply don't understand how this is possible, I know the parameter and the settings for the tables are exactly the same as I just copied and pasted the table and simply changed the condition for each different table.

I have also tried changing the expression to something like:

=IIf(Fields.BankMovementType = "EFFECTIVE", Exec("table4",IIF(NetPayment > 0,Sum(NetPayment),"")),"")

but it still shows empty and I just simply don't understand what is wrong with it, it doesn't even give any errors, it just simply doesn't do what its supposed to do...

I have attached images of the resulting tables to better understand what I'm trying to say, the first one is from the table that actually works and the second one is form the one that doesn't do its job. The final image is a picture of how they are structured on the designer.

 

 

4 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 06 Jul 2017, 10:26 AM
Hello Seth,

Without knowing the exact settings of the report and the data used for the tables is would be hard to say what might be the cause of this issue.

Test using only the true part of the IIF function in the expression (= Exec("table4", IIF(NetPayment > 0, Sum(NetPayment), ""))). This will allow you to see if the condition Fields.BankMovementType = "EFFECTIVE" evaluates to false and to narrow the area which needs to be corrected.

To provide you further suggestions, post some sample data that is used for the problematic tables in a text format so we can test your scenario on our side.


Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
seth
Top achievements
Rank 1
answered on 06 Jul 2017, 05:10 PM

I did just what you said and it actually worked, it is now calculating the sumatory field, I don't really understand why this is happening as the rest of the fields on the table use the exact same Expression end they are actually showing up on the table, for example this one:

=IIf(Fields.BankMovementType = "EFFECTIVE", Fields.CompanyBankName,"")

doesnt output any empty fields...

My only problem now is that its rounding up the numbers when adding up the fields for some reason, this is a big problem as the quantity displayed needs to be exact since this is a report for accounting. Is there a way to make the sum function not round up the numbers when calculating? I even changed the type of the calculated from 

NetPayment (Double)  =IIf(Fields.BankMovementType = "EFFECTIVE", (Fields.Perception -  Fields.Deduction),0)

to 

NetPayment (Decimal)  =IIf(Fields.BankMovementType = "EFFECTIVE", (Fields.Perception -  Fields.Deduction),0)

but it doesnt seem to change anything... I attached a picture of an example too.

0
Katia
Telerik team
answered on 07 Jul 2017, 03:06 PM
Hello Seth,

Check this forum post which describes a possible solution for the issue you are having. The main idea is to use conversion functions to make sure that you work with the correct data type inside expressions.

Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
seth
Top achievements
Rank 1
answered on 07 Jul 2017, 04:21 PM

I was already able to solve the problem, when I change the function to:

=Exec("table3",Sum(Ceiling(NetPayment * 100)/100))

it works as intended, I still don't know why the first table didn't give me so much trouble as compared to the other ones but its solved now...

Tags
General Discussions
Asked by
seth
Top achievements
Rank 1
Answers by
Katia
Telerik team
seth
Top achievements
Rank 1
Share this question
or