I am grouping my report using two fields Field A and Field B.
I want the user to be able to either group by Field A and Field B or only by Field A. In both cases I want the details to be sorted on the basis of Field C.
You can create a parameter that will allow the user to pick which field. The parameter should be String type and the default values should be "Field A and B" and "Field A".
Create a formula that will return the appropriate field(s) based upon what the user picks in teh parameter.
@Dynamic_Group
If {?Param1} = "Field A and B" then
{table.fieldA} & {table.fieldB}
Else
{table.fieldA}
Now you can insert a group based upon the @Dynamic_Group
formula.
Lastly, add Field C to the Record Sort Expert.
Grouping will place the rows in the group order first, you can subsort the rows by any other column (such as Field C by using Report->Sort Records (this is CR version dependent).
As for changing the grouping, create a parameter to allow the user to select the type of grouping, and then a formula to use as the group:
Creata a parameter:
In the Field Exploere, right click parameters and select new->name it
Slect type string and then choose set default values
In the default values use:
Field A
Field A & B
Save it
Now create a formula such as:
If {?MyParm = "Field A" then
{table.fielda}
else
{table.fielda}+{table.fieldb}
Now use Insert->Group and select the formula you created.
The report will now prompt for which grouping to use.
Thanks bdreed35 and synapsevampire. Your solution worked well.
I am using this report under Visual Studio.NET. Is there a way to set the parameter's value using code. I figured out there's a method ReportObject.setparametervalue and it probably does seem to set the value.
But, before I can set the value, the report gets loaded (in the CrystalReportViewer control) and the prompt for the parameter pops in.
So I guess, my problem now is how to prevent loading the report in the CrystalReportViewer unless prompted to do so?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.