I am using VB.Net 2010 with Crystal Reports. I have designed a pivot query that returns the required summary information.
NOTE: I do not want to use cross tab because I need to display the information from right to left.
The following is a sample result:
Simply I am summarizing the number of employees for each rank for every nationality. That is when I modify any employee's nationality, that nationality will appear as a column in the result: PIVOT.
I designed a crystal report that uses the same query and display the same data.
I set the data source of the report to a command and added the query in the command, But here is the problem: The number of columns returned by the query are only those retrieved when running the query at design time! That is, if new employee from an other nationality is added to the database it would not be possible to be displayed in the report. Or even, the maximum number of columns as per the columns set is 3.
My question is:
How can I add these columns dynamically based on the number of columns returned by the pivot query?
MODIFICATION:
As per the suggestions below, I designed a crystal report that uses a dataset with one datatable "DataTable1" and added 6 columns: one for Rank that is fixed, and the other columns are for the possible nationalities that may exist in my employee data table as the following picture:
The question now is how display the data returned by the pivot query in these columns? And how hide the other columns that no data are placed on them?