Display DataTable with Group By in report

Posted on 2011-05-02
Last Modified: 2013-12-16

I need to display a DataTable in a report.
So as the DataTable is not grouped or sorted in any case I need a way to display the DataTable using different Group By options (e.g. by Date, by Customer ...).

As I'm doing my first report in this way with VS 2008 and reporting services maybe you can give me a hint how to make the report.
I think I've to use different reports for any case I need like:
1. Report by date
2. Report by customer

And how to group the data - can Crystal Report do so or have I need to use something like LinQ?
As the DataTable will bild in memory I can' use something like a group by query ...


Question by:andre72
    LVL 4

    Expert Comment

    Perhaps if you give a detailed description of how you want the data laid out I could help. For example:

    I want 1 report with 2 tables, Table A is sorted/grouped like...., Table B is sorted/grouped like....


    I want a subreport that is grouped like..., while the main report is grouped like....
    LVL 100

    Expert Comment

    Are you trying to do this is MS SSRS or Crystal?

    Both tools can handle the report.
    How you do that depends on which tool you choose.

    In Crystal you can use a formula for the grouping and have a parameter that the user enters to choose the field to group on

    If {?GroupParameter} = 'Date' then
    Else  if {?GroupParameter} = 'Name' then

    The only restriction with this method is the formula can only return 1 datattype so in general you have to convert everything to strings.


    Author Comment

    I'm not sure about MS SSRS or Crystal.
    Is one of both able to do HTML export?

    I've only one not grouped and not sorted table:
    Customer  Date  Amount

    Ok, gouping and sorting will also be no magic with LinQ I think if it's pissible.

    The two reports I need are:
    Group by cate and for every day a total sum
    Group by customer with sum for every customer

    With Access it would talke less than 5 minutes I think but with VS I give it my first try ...
    LVL 100

    Expert Comment

    I know Crystal can export to HTML and PDF.  I believe SSRS can also.

    Crystal can group and sort as you want.

    Crystal is much like Access in report development.


    Author Comment

    Than I decide to choose Crystal, thanks.
    Can you point out the first steps?

    The samples I saw are ever based on a connection to a DB but my DataTable is allready in memory ...
    LVL 100

    Accepted Solution

    This question has 1 example

    Here is another of passing the dataset to Crystal

    I haven't found a VS2008 version but the basic steps for building a report should be the same as VS2005 Crystal


    Author Comment

    Thanks this works fine at all.
    My only problem is to build the sum of the amount data.
    In the section footer the field for the sum is available and when I edit it I can choose many kind of result:

    But not the sum ...
    How can I place the sum there?
    LVL 100

    Expert Comment

    Apparently the field is not a number.  If it is numeric data as strings you can use the Val function to convert it in a formula then sum the formula



    Author Closing Comment

    Thanks I will open a new thread for my sum problem ...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Flash ( has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now