crystal-reportscrystal-reports-2008crystal-reports-2010crystal-reports-xi

Crystal Report remove group sorting when group is conditionally suppressed


I have a Crystal Report with three (3) groups: Group1 = Location, Group2 = Create Date, Group3 = Case ID. I have a parameter asking the user if they want to display Location (Group1) by selecting Yes or No. The report will suppress Location (Group1) when the parameter = No, but the report continues to sort the results by Location (Group1) first. If my display Location (Group1) parameter = No, I would like the report to first sort by Create Date (Group2). Is there a way to accomplish this?


Solution

    1. Let's suppose that the name of the parameter mentioned by you is "TheParameter", and your data is on a table named "Table" with a column named "Location".
    2. Create a formula like below. Let's call it "TheFormula".

      if {?TheParameter} = "No" then "" else {Table.Location}

    3. Change your group1. It shall group by "TheFormula" instead of "Location".

    That is it. Now, if the user says "Yes", the report will be grouped by location. But if the user says "No", the first group will do nothing.