views:

345

answers:

2

I have a report that is currently separated into two reports, and I'd like to merge them.

Basically it boils down to this:

I ask the user if they want to have a page break for each Property, if they answer yes, I sort/group by Property and then I sort by X
If the user answers no, I want to just sort/group by X

I've tried suppressing the initial Grouping if the user answers No, but it still sorts accordingly (not how I want it to).

How can I do this without keeping it in two reports?

+2  A: 

Instead of suppressing the grouping field, try setting it to an empty string "". I was just working on a report last week that was very similar. Even if 'no grouping' was selected, the report was still being grouped by some unknown default. In the formula grouping field, I found that if 'no grouping' was selected the field was not getting set at all. Once I changed it to set the field to an empty string, the report generated as expected.

Matthew Ives
That doesn't work because the subgrouping then tries to match to the Property of ""
Malfist
It worked just fine for me. What does your conditional look like in the grouping formula field?
Matthew Ives
if {?doPageBreak} then {tblProperty.PropertyName} else ""
Malfist
+1  A: 

Are you grouping or sorting? If you do not use the group header/footer it is basically the same as sorting and you should simply use the record sort.

In general, to conditionally group fields you would use formulas. For this to work the fields in question need to be returned as the same type: number, string, date, etc. In your case it sounds like the first grouping formula would be like this...

//{?break_by_property} would be the parameter value to control the page break

if {?break_by_property) then
{the_property_field}
else
"" //any static value of the same type as {the_property_field}

now go the "new page before" formula for that group header and enter this boolean formula (groupnumber is a special keyword)...

{?break_by_property} and groupnumber > 1

then add a record sort for X.

dotjoe
I don't quite understand you. If the user wants page breaks then I sort by Y then I sort by X (because they're joined on an FK), if the user doesn't want page breaks, I just want to sort by X. If I replace the initial group with "", that is linked to no FK on the X's table, therefor, no X gets displayed. :(
Malfist
using a static value essentially removes that first group since all data will be in that one group. Don't you want to either page break (i.e group and add new page in group header) by Y and sort by X or only sort by x? This will do that. I don't understand your concerns about the FK link. The formula has nothing to do with the table link.
dotjoe
Because if I return "", there are no X's joined to "", they are only joined to {the_property_field}. If I change it to what you're suggesting I get an empty report.
Malfist
it's not even possible to join tables by a formula field. X will still be linked to the correct field if you go to the database expert. This is only a report grouping...maybe there is another problem with the display? You're not using the group field in the record select are you?
dotjoe
It doesn't matter, I'm replacing everything with a stored procedure :)
Malfist