Displaying sum of nested JSON data in a table using Telerik Designer

1 Answer 256 Views
Binding DataSource JSON DataSources Expressions Report Designer (standalone)
IntegraTools
Top achievements
Rank 1
IntegraTools asked on 17 Mar 2023, 12:11 PM

We have a case where we have the following json data source as the source of data:

{
    "Transaction":
    {
        "ProductList": {
            "Product":[
                {
                    "@Item": "Product Name 001",
                    "@Price": 1.00,
                    "Taxes": {
                        "Tax" :[
                            {
                                "@Type": "TaxType1",
                                "@Amount": 1.00
                            },
                            {
                            "@Type": "TaxType2",
                            "@Amount": 2.00
                            }
                        ]
                    }
                },
                {
                    "@Item": "Product Name 002",
                    "@Price": 1.00,
                    "Taxes": {
                        "Tax" :[
                            {
                                "@Type": "TaxType2",
                                "@Amount": 1.00
                            },
                            {
                            "@Type": "TaxType2",
                            "@Amount": 2.00
                            }
                        ]
                    }
                }
            ]
        }
    }
}

We have imported it into Telerik Designer in such a way that it appears like this in the Data Source Explorer:

We want to display in a table, for each Product line, the sum of all its Product.Taxes.Tax.Amount in addition to the product's own data. e.g
ProductName 001 | Product Price 001 | Sum(Product.Taxes.Tax.Amount) for Product 1
ProductName 002 | Product Price 002 | Sum(Product.Taxes.Tax.Amount) for Product 2

We can easily access attributes of Product such as "Item" or "Price". The problem arises when we want to access the sum of the Product.Taxes.Tax.Amount for each product.

It seems that the expression editor and Data Source configurator is not able to reach the depth level of Product.Taxes.Tax.Amount. We tried to acces via JSON Path in the Data Source but didn't work

How can we represent the Product.Taxes.Tax.Amount sum for each Product in a table?

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 22 Mar 2023, 09:43 AM

Hello Marcel,

Thank you for the provided data sample and the additional information!

In order to sum the values of the Tax array field, that field must be bound as the data source of a data item using bindings.

For example:

The scenario from this image is that I have the data source component attached to the Report.DataSource, and I have inserted a table to which I have bound its DataSource to the Fields.Taxes.Tax field - Binding to Data Overview - Telerik Reporting.

I have attached a sample report with this data in order to demonstrate this approach. The report was created with the latest version of Telerik Reporting, so it has the latest report schema. You may need to install the latest release to open it in your report designer or you may open the TRDP file with a zip archiver and you may modify the internal XML defintion file's schema.

Please let me know if you have any further questions.

Regards,
Dimitar
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Marcel
Top achievements
Rank 1
commented on 23 Mar 2023, 02:31 PM

Thanks Dimitar! It worked for us =)
Tags
Binding DataSource JSON DataSources Expressions Report Designer (standalone)
Asked by
IntegraTools
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or