How to sum a row dynamically from different lists in json format

 

I have a report and i need to sum a row from different different product.

Example: 

[
          {
            "insuranceProductName": "Life",
            "paymentGraph": [
              {
                "year": 1,
                "premiumPerPeriod": 0.54
              },
              {
                "year": 2,
                "premiumPerPeriod": 9.03
              },
              {
                "year": 3,
                "premiumPerPeriod": 10
              }
            ]
 
          },
          {
            "insuranceProductName": "Job",
            "paymentGraph": [
              {
                "year": 1,
                "premiumPerPeriod": 9.03
              },
              {
                "year": 2,
                "premiumPerPeriod": 9.03
              },
              {
                "year": 3,
                "premiumPerPeriod": 9.03
              }
            ]
          }
        ]

So i need to sum insuranceProductName: Life first year premiumPerPeriod with insuranceProductName: Job first year premiumPerPeriod.

insuranceProductName: Life second year premiumPerPeriod with insuranceProductName: Job second year premiumPerPeriod. and so on.

But it must be counted dynamically, because I don't know how may products or paymentGraphs gonna be there.

Example how it should look:

So total for all is easy to count, but I'm struggling with counting separate totals, like for first year is 32,44, which I don't know how to count dynamically.

This is how it looks now, i did all products with lists. The subreport hold names and a list with ????, is where I'm trying to do that sum.

Thank you so much for your response.

kliuvinis1's picture
Joined: Mar 31 2022 - 5:51am
Last seen: 9 months 2 days ago

1 Answer:

You can use a variable that adds up the individual fields and display it.  You can then create a sum on the variable.

sanderse's picture
4507
Joined: Jul 31 2017 - 3:51pm
Last seen: 5 hours 42 min ago
Feedback