Order by a group

Stimulsoft Reports.NET discussion
Post Reply
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Order by a group

Post by Fabio Pagano »

I have a datatable that has all the expirations amounts of all the customers.

In each row (representing an expiration) i have the name of the customer and the amount of the debt to pay for that single expiration.

I need a report where i have the total expirations for each customers, ordered by total expirations value.

Example:

Original datatable:

Mr Smith 100,00
Mr Smith 42,00

Mr Ross 30,00
Mr Ross 80,00

Mr White 400,00
Mr White 10,00

I need this final result:

- Report ordered for descending total expirations amounts:

Mr White: Tot. 410,00
Mr Smith: Tot. 142,00
Mr Ross: Tot. 110,00

How can i do this?

Thanks.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Order by a group

Post by Vital »

Add to page GroupHeaderBand and DataBand. Set height of DataBand to zero. Set condition of GroupHeaderBand to {representing}. Set property SortDirection of GroupHeaderBand to Descending. Place textbox to GroupHeaderBand and type following expression: {representing} {Sum(expiration)}.

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Order by a group

Post by Fabio Pagano »

Sorry, i receive two compiling errors (the same error but twice):

(translated from Italian)

-> error CS0103: The name "representing" doesn't exist in current context

Thanks.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Order by a group

Post by Vital »

Instead {representing} you need use {YourDataSource.ColumnName}.

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Order by a group

Post by Fabio Pagano »

No error, but the output is ordered by "Customer name" in descending order, while i wanted it to be ordered by "Total expiration amount" (of each Customer) in descending order.

I have assumed that to {representing} i have to substitute the "Customer name" column.

Thanks.
Brendan
Posts: 309
Joined: Sun Jul 16, 2006 12:42 pm
Location: Ireland

Order by a group

Post by Brendan »

Sometimes I use the "Data from other Datasource" to do stuff like this.

You can Create a new Datasource in your report based off an existing Datasource registered with the report.
This way you can group by Customer Name, and Total the amount into their own columns respectively.

You can then add this new Datasource to the Page as a Databand and Sort by Amount.Sum descending.

Sample: Download

But maybe there's an even quicker approach? This is just what I do.
Post Reply