Add table for sum of all the values

I need a table at the bottom with the sum of all the values in the value column.
How can I do it or what will be the good approach?

Screen Shot 2017-03-27 at 14.11.04

Hi Sanchit,

Please take a look at the similar example in our Sampler.
More information on the aggregated columns you can find in the documentation.

Hi Olga,

I mean I only need one table at the bottom with the sum of ‘‘Amounts’’ in this case.

Do you mean, your table should display only the “Amounts” and nothing more? Could you please explain the expected result in more details or draw a simple example?

I want a separate table with only one column displaying sum of ‘‘Amounts’’.
Is it possible?

Would it be possible to use the new Value Datasources feature to achieve this?

Yes, in this case, a Value Datasource is worth using. Create a property for calculating the sum and make the table display only this column.

Hi,
I’m using Value Datasource but I am getting an error when I create a property.

‘‘Choose a value for ‘attribute-name’ property from one of the columns: datatype or class’’.

Please help me.

Thanks
Sanchit

Did you try to choose a value from one of the two columns? This message occurs when none or both datatype and class values are selected, you need to select only one of them.
For example:


        <valueGroupDatasource id="sumDs">
            <query>
                <![CDATA[select e.name, sum(e.amount)
                    from sum$SomeEntity e
                    group by e.name]]>
            </query>
            <properties idProperty="name">
                <property class="com.company.sum.entity.SomeEntity"
                          name="name"/>
                <property datatype="decimal"
                          name="total"/>
            </properties>
        </valueGroupDatasource>

I try to do the same as Sanchit using valueGroupDatasource or valueCollectionDatasource (not sure which would the right one).

On my “Article” screen I want to have the sum of all ordered Articles (amount) from table “Order”

My best guess would be:

select sum(o.amount) from demo$Order o
where o.article.id = :ds$articleDs

But this throws a “IllegalStateException: query path ‘o.article.id’ is unresolved”

If I remove the where clause, it returns the sum of all orders.
It also works to group by article but I don’t need the list of all articles, only the one of interest.

However, i can use a “collectionDatasource” to get all orders for the article using the very same where clause:

select o from demo$Order o
where o.article.id = :ds$articleDs