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

display errors when calculating totals in my report

6 Answers 96 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Wassim
Top achievements
Rank 1
Veteran
Iron
Wassim asked on 26 Mar 2021, 11:01 AM

Hello,

I created a report to display values and totals.
I have a problem with the Bordereau N ° 212319
it shows me the total of "Nombre de Plis" in just "DD" column (1 233) while it should appears to display (897 in "DD" and 316 in "TF") as the capture that I have attached. Same problem in "Poids Total"

I am sharing my sample with you online via Dropbox. please check this and advise me any way to address this requirement.

https://www.dropbox.com/s/zts6gyiefp5qdce/myReport.trdp?dl=0
Thanks in advance.

6 Answers, 1 is accepted

Sort by
0
Wassim
Top achievements
Rank 1
Veteran
Iron
answered on 30 Mar 2021, 01:06 PM
Any idea or suggestions please ?
0
Dimitar
Telerik team
answered on 31 Mar 2021, 02:26 PM

Hello Wassim,

I inspected the report and there seem to be some issues with the expressions being used for the data in the columns.

For example in the DD column where it is showing 1233, the problem is that you using the Sum() function to sum all the values, therefore the returned value is not as expected. Returning just the field corrected the issue and now the returning value was as expected 897.

Regarding the TF column, the reason that it is displaying 0 instead of 316 is that the IIf function returning the false value, which you have set to 0 because the tested expression is being evaluated to False. It seems that this is the issue with the other fields too, the IIf expressions are returning the false values which you have set to be zero.

Please, test to correct your logic/expressions to work as you expect them to. You may also try moving the content from the group header section to the details section.

Please let me know if you have any other questions or need further assistance.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Wassim
Top achievements
Rank 1
Veteran
Iron
answered on 31 Mar 2021, 03:24 PM

Hello Dimitar, 

Thanks for replying.Yes you are right.

I have modified the content of each column by removing the Sum function and returning only the field but the concern I have is how to display the right value according to the type of presentation (CP or DD or TF)
I thought the logic I should use is IIF .. assume that an element has both types of presentation CP and DD
= IIf (Fields.PRESENTATION = "CP", Fields.NB_PLIS, 0)
it displays the value NB_Plis in the CP column or 0 if not
= IIf (Fields.PRESENTATION = "DD", Fields.NB_PLIS, 0)
it displays the value NB_Plis in the DD column or 0 if not
I wonder what is the problem in the logic that I used?

Another thing, I moved the content from the group header section to the details section, I got a two line item if it has two types of presentation as the attachment capture shows. .but the total at the report footer level does not display correctly depending on the type of presentation?

I attach the report after the changes I made

https://www.dropbox.com/s/clo3bj2llzk44pf/myReportAfterChanges.trdp?dl=0

0
Dimitar
Telerik team
answered on 05 Apr 2021, 01:17 PM

Hello Wassim,

I inspected the modified report and after doing some major changes I was able to achieve what I believe to be the desired result.

For starters, the reason for the "212319" field showing two times, is that in the JSON data source itself there are two objects that have that value for the NO_BORDEREAU field and the textBoxes were placed inside the detail section. The details section gets printed for each row of data and since two objects mean pretty much two rows, it gets printed twice.

This leaves two options in such a case:

  • Place the textBoxes that display these fields inside a Group section, in the group section only the first row of the 2 will get printed.
  • Modify the data so that there are no 2 objects for the field NO_BORDEREAU  

I modified the data so that for the 212319 there is one object and the fields where there were differences, I made into arrays:

 {
      "CTC_DEPOT":"ONET LE CHATEAU PPDC",
      "DATE_DEPOT":"2020-09",
      "NO_CONTRAT_DEPOSANT":"",
      "NOM_DEPOSANT":"EDOKIAL",
      "NO_CLIENT_DEPOSANT":"00405",
      "NUMERO_REF":"00027262",
      "LB_PRODUIT_LONG":"TEMPOST G2",
      "LIB_OPTION_AFF":"BASE",
      "NO_BORDEREAU":212319,
      "LIB_SERVICE":"Alliage Premium avec destruction du pli",
      "PRODUIT":"TMPOST G2",
      "MECA":"PF",
      "PRESENTATION":"DD",
      "TRANCHE":"0-50g",
      "NB_PLIS":897,
      "POIDS":1.376000000000000e+004,
      "TARIF":5.157700000000000e+002
   },
   {
      "CTC_DEPOT":"ONET LE CHATEAU PPDC",
      "DATE_DEPOT":"2020-09",
      "NO_CONTRAT_DEPOSANT":"",
      "NOM_DEPOSANT":"EDOKIAL",
      "NO_CLIENT_DEPOSANT":"00405",
      "NUMERO_REF":"00027262",
      "LB_PRODUIT_LONG":"TEMPOST G2",
      "LIB_OPTION_AFF":"BASE",
      "NO_BORDEREAU":212319,
      "LIB_SERVICE":"Alliage Premium avec destruction du pli",
      "PRODUIT":"TMPOST G2",
      "MECA":"PF",
      "PRESENTATION":"TF",
      "TRANCHE":"0-50g",
      "NB_PLIS":316,
      "POIDS":4.590000000000000e+003,
      "TARIF":1.908600000000000e+002
   },

Got turned into:

 {
      "CTC_DEPOT":"ONET LE CHATEAU PPDC",
      "DATE_DEPOT":"2020-09",
      "NO_CONTRAT_DEPOSANT":"",
      "NOM_DEPOSANT":"EDOKIAL",
      "NO_CLIENT_DEPOSANT":"00405",
      "NUMERO_REF":"00027262",
      "LB_PRODUIT_LONG":"TEMPOST G2",
      "LIB_OPTION_AFF":"BASE",
      "NO_BORDEREAU":212319,
      "LIB_SERVICE":"Alliage Premium avec destruction du pli",
      "PRODUIT":"TMPOST G2",
      "MECA":"PF",
      "PRESENTATION":[
         "TF",
         "DD"
      ],
      "TRANCHE":"0-50g",
      "NB_PLIS":[
         316,
         897
      ],
      "POIDS":[
         4.590000000000000e+003,
         1.376000000000000e+004
      ],
      "TARIF":[
         1.908600000000000e+002,
         5.157700000000000e+002
      ]
   },

I also change the marked with light blue fields into arrays for the other object, in order to keep consistency.

After that, I modified all the expressions for using arrays. The easiest way to get an item from an array field is through the Item function which returns the element of the collection with the given index (zero-based).

I have attached the report with my changes, please check it out carefully and let me know if you have any other questions or need further assistance.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Wassim
Top achievements
Rank 1
Veteran
Iron
answered on 06 Apr 2021, 09:51 AM

Hello Dimitar,

The concern is that I cannot change the data like you did, because I get the data by executing an sql query and moreover I don't have a static NO_BORDEREAU  (I have attached a  screenshot ) on which I can test, there are quite a few elements which have Nb_Plis/Poids with presentation types (CP, DD, TF)
is there any other way to display the correct values depending on the presentation type without changing the data ?

 

regards,

Wassim

0
Accepted
Dimitar
Telerik team
answered on 07 Apr 2021, 01:10 PM

Hello Wassim,

I tried once again to find a solution for this case and I believe that this time I was able to find it without requiring changes in the data.

Basically, like my last suggestion, I had to move the TextBoxes from the detail section to the group section so that we do not see 2 objects with the same ID repeatedly.

The core part of the solution is changing just slightly the expressions in the TextBoxes, for example in the TF field for the Nombre de Plis, it used to be like this:

= IIf(Fields.PRESENTATION = "TF", Fields.NB_PLIS,0)

The problem with this is that the first object has PRESENTATION: "DD" so here the test fails and the displayed value is 0 instead. To solve this, I modified the statement like the following:

= Sum(Fields.PRESENTATION = "TF" ? Fields.NB_PLIS : 0)

This way, for each group, it will check every object what his PRESENTATION value is and if it is "TF" it will add that value to the sum. If it is DD, it will add 0, and this way the sum will not change. By the way, the logic inside the Sum() function is like IIf() function but instead, the ternary operator is being used.

I used similar logic in a lot of expressions in order to achieve what I believe to be the desired results. I have attached the modified report to my reply. 

Please let me know if you require further help.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Report Designer (standalone)
Asked by
Wassim
Top achievements
Rank 1
Veteran
Iron
Answers by
Wassim
Top achievements
Rank 1
Veteran
Iron
Dimitar
Telerik team
Share this question
or