Simple report, no groups, but I want allow the user to select the field to sort by i.e. by DueDate or by Responsible, possible using a parameter field ?
My suggestion to you in this case would be to send the user an Excel export version of your report. This way they can use the excel datasort option to sort by whichever column they choose.
Step 1) Create Parameter Field called {?SortOrder}, Value Type = String, with Default Values equal to the column names by which you wish to sort (Example: UserName, UserId, etc...).
Step 2) Create a Formula Field called {@SortOrder}. Within this formula, create a formula similar to the following:
StringVar SortOrderVar;
If {?SortOrder} = "UserID" then SortOrderVar := {TableName.UserID} else
If {?SortOrder} = "UserName" then SortOrderVar := {TableName.UserName};
Insert {@SortOrder} into the report. This formula can be hidden if you choose.
Step 3) Sort by {@SortOrder}.
There are a few things to take into consideration here:
Since you declared a variable (stringvar in my example), the values need to be the same type as the string. If you use ToText on a numeric field, keep in mind that the records may not be sorted in the manner you expect (ex: 10, 2, 3, 4, 5, 6, 7, 8, 9 ).
Don't use the WhilePrintingRecords function because you can't sort by a formula that contains it due to the evaluation time.
This is interesting, however is it therefore possible to specify ASCENDING or DESCENDING too? This could potentially be a very powerful piece of functionality for me, so any thoughts would be much appreciated.
YES...create 2 groups with the same formula as described above... except each modified as follows:
formula for group 1
If {?SortOrder} = "UserID" and {?sortdir} = "ASC" then SortOrderVar1 := {TableName.UserID}
else If {?SortOrder} = "UserName" and {?sortdir} = "ASC" then SortOrderVar1 := {TableName.UserName}
else SortOrderVar1 = "1";
formula for group 2
If {?SortOrder} = "UserID" and {?sortdir} = "DES" then SortOrderVar2 := {TableName.UserID}
else If {?SortOrder} = "UserName" and {?sortdir} = "DES" then SortOrderVar2 := {TableName.UserName}
else SortOrderVar2 = "1";
in "the Change Group options" Group 1 would have the records sorted "Desending" whereas Group 2 would have the records sorted "Ascending".
Note: the only differences betwwen these formulas is that one group or the or is set to a constant (ie. the group has no effect) depending on the new parameter called "Sortdir"
if you have stuff you want displayed in the header or footers of these groups just make sure the fields are the same in both headers or footers and suppress the group you don't want to see....otherwise if there are not fields in these sections then jus suppress headers and footers for these groups
never tried this before but it should work....will keep it mind for myself...thanks for the idea
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.