GROUP SORT PARAMETER

I have a report with a group sort of the "Top N" items based on profit.  I already have a parameter that allows the user to specify the "N", but I want to also give the option to change the group sort based on sales or units sold.  Is there a way to do that?

hello all,
actually Brian's solution is correct...i use this method all the time.
add two more steps to his solution...you should have created a formula with syntax
Select {?GroupField}
   Case "Sales" :{table.SALES}
   Case "Units Sold" :{table.UNITS_SOLD}
   Default :{table.SALES};
1) now add this formula to the details section, right click on it, and add a Summary, type = Sum.
2) now go to the Group Sort Expert and add the formula, removing any other sorts in there already.
you can now sort the groups on this formula that he gave you.
if you have crystal reports 2008 or 2011 you can also use Interactive Sorts instead of using a parameter / prompt.
cheers,
jamie

Similar Messages

  • Use parameter to specify "N" in Top N Group Sort

    I've successfuly set up a parameter which is passed to the Group N Sort criteria.
    Is there a way I can use this to set NO group sort? I've tried setting it to zero & 999999999 but it falls over.

    I think you can enter the values only between 1 to 32767. You can try creating a sample report with groups in it and go to group sort expert and select top N and try to add the value 0 then you will get a popup saying "Please enter an integer between 1 and 32767"
    Regards,
    Raghavendra

  • How do I change the number in a Top N Group Sort

    I have a report that I have grouped on a particular field (Cust.Name specifically). I then used the group sort expert and selected the Top N selection in the combo box under the Cust.Name tab. I put in a default number of 20. What I want to do is to set this number for the Top N group sort via .NET. Does anyone know the correct method for doing this in either VB.NET or C#.NET. I am using VS 2005 Pro and the embedded Crystal Reports engine for VS.NET. Thank you.
    Ed Cohen

    Hello, Edgar;
    In the bundled version of Crystal Reports 10.2 in Visual Studio .NET 2005 you will need to use the following code:
    Private Sub Set_TopN()
            Dim TopNSortField As TopBottomNSortField
            'Get the Sort field by index
            'Cast it as a TopBottomNSortField
            If TypeOf crReportDocument.DataDefinition.SortFields.Item(0) Is TopBottomNSortField Then
                TopNSortField = crReportDocument.DataDefinition.SortFields.Item(0)
                TopNSortField.NumberOfTopOrBottomNGroups = 10
            Else
                TopNSortField = Nothing
            End If
        End Sub
    In a full version of Crystal Reports there is an option to create a parameter as a number such as {?TopN} and then pass the value to it at runtime.
    In the Crystal Reports designer you need to create the parameter and then go to Report|Group Sort Expert.
    Choose TopN based on your field.
    Where N is... You will need a number there. I used 1. But then I clicked on the Formula editor [X+2] and added the parameter field {?TopN}.
    Passing the parameter at runtime ran the number I requested.
    Elaine
    Edited by: Elaine Dove on Mar 3, 2009 12:12 PM

  • Sum of a sum when using Top N in the Group Sort Expert

    Hi All,
    I have a small problem I can't quite seem to work out.
    I have a report where each line is for a particular Product, and is a summation of the Sales for that Product over several Locations. When you click on the line, it shows the breakdown of Sales over each Location.
    I use the Group Sort Expert to display the Top N results, where the 'N" is set in a formula to a parameter passed in to the report, so the user can select the top 5,10,50 etc. Products across all Locations.
    At the bottom of the report, I want to have a sum of a column of Sales $. I need that sum to only be a sum of the Top N records selected.
    Since each line is a summation of the all the products for the Locations, what I need is a sum of that sum for the Top N, but Crystal will not let you add the sum of a sum, so I'm not sure how to accomplish this.
    If I just do a sum of the underlying values I get a total for all the Products, regardless of the Top N.
    Hope that makes some sense !
    Many Thanks
    Paul

    Hi Sastry,
    I tried your suggestion, thanks, but I don't think it's the answer. For a start Crystal will not let me do that, it pops up a message box when I try to run the report "A running total cannot refer to a print time formula. Details: Record Number". I also added the record number field next to the lines in the report to see what the result would be, and I don't think it would work anyway.
    Here is an example using Units sold:
    Product Name--LocationUnits Sold--Record Number
    Product A -<All Stores>----8
    Store A--1--
    1
    Store B--3--
    2
    Store C--4--
    3
    Product B--<All Stores>--3      
    Store A--2--
    4
    Store B--1--
    5
    Product C--<All Stores>--
    1
    Store A--1--
    6
    Note that only the bold lines are shown in the report,. If you click on the bold line, then the breakdown of the stores is shown. For the above example, I am showing the Top 2 units across all stores (so Product C is not shown at all), but there are actually 5 records, so if I used a formula where RecordNumber <=N, where in this case N=2, I would get a total units sold of 1 + 3 (records 1 and 2) which is incorrect.
    I will have more of a think on this and see if I can find a solution, in the mean time, any other suggestions ? Is there some wya of checking if the line is visible maybe ?
    Thanks for your time !
    Paul

  • Group Sort Expert Top N

    In Group Sort Expert I have a group called @Sku and I want to select the top 500 based on Sum of @SortByData which works except the totals are for the whole group and not just the top 500.
    Also I would like to select Ascending/Descending based on a parameter field IN the Group Sort Expert since I'm using a based on field (not in Group Expert Change Group Options).

    Hi sharonamtowler,
    My requiremnet is TOP N Materials based on the Current Availiable Stock in each Plant.  In CR from my db, I get four records in Details section for each Material (on 4 weeks, let say 48,49,50,51 ) of a Plant.
    I have grouped on Plant & material. 
    But to get Top N Materials I have to do Summation(Current Availiable Stk) which mean in My Material Group Section I get the Sum of Current availibale Stock of 4 weeks. But I need Top N based on the last weeks Current Availible Stock.
    How to do this?
    I left Plant in Group Sort Expert with No Sort and on Material I have given TOP N.
    I need to know whether only Summation Values should be used in Group sort expert ?
    please some help me solvethe issue.
    Edited by: KRISHNA CHAITANYA B on Dec 29, 2009 6:12 AM

  • Group Sort ALV

    Hi,
    Is it possible to group sort on ALV?
    it seems we are able to merge together several rows via sort but only on its field level.  is it possible to be a group field level?
    example if i sort PO number first and vendor second it will have individual PO and the vendor field is merge together if it is the same with a different PO.  Can we make the PO number as the first priority sorting without changing the position of the fields?

    c z wrote:
    Hi,
    >
    > Is it possible to group sort on ALV?
    >
    > it seems we are able to merge together several rows via sort but only on its field level.  is it possible to be a group field level?
    >
    > example if i sort PO number first and vendor second it will have individual PO and the vendor field is merge together if it is the same with a different PO.  Can we make the PO number as the first priority sorting without changing the position of the fields?
    If I have understood your requirement correctly, group sorting should be as simple as filling up the 'IT_SORT' parameter(REUSE_ALV_GRID_DISPLAY/REUSE_ALV_LIST_DISPLAY/CL_GUI_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY)
    as shown below: (please let me know if I have misunderstood your requirement).
    ls_sort-spos = '1'.
      ls_sort-fieldname = 'FIELD1'.
      ls_sort-up = 'X'.
      APPEND ls_sort TO it_sort.
      CLEAR ls_sort.
      ls_sort-spos = '2'.
      ls_sort-fieldname = 'FIELD2'.
      ls_sort-up = 'X'.
      APPEND ls_sort TO it_sort.
      CLEAR ls_sort.
    Even after displaying the ALV, columns can be group sorted by selecting all of them together(by dragging the cursor over all the columns that need to be sorted)
    -Rajesh.

  • Series group sorting

    Hi
    I am facing one problem. In my report i need to change chart order series group sorting by report parameter
    value. Is it impossible?
    thanx in advence.

    Hi Unbeliever,
    Per my understanding you have an parameter and the order of the series group will sort based on the  value in the parameter selected, right?
    I assumed that you have two values in the parameter(ASC,DESC) to define the order. you can add an expression in the Series group to change the order based on this parameter.
    Details information below for your reference:
    Right click the Series group to select the "Series Group properties".
    Select the "Sorting" and add expression below to conditional change order(By default the order is ASC):
    =IIF(Parameters!Order.Value="ASC",Fields!CarModel.Value,switch(Fields!CarModel.Value="LXI",5,
    Fields!CarModel.Value="Test1",4,
    Fields!CarModel.Value="Test2",3,
    Fields!CarModel.Value="VXI",2,Fields!CarModel.Value="ZXI",1))
    Preview you will got the chart display as below:
    If your problem still exists, please try to provide more details information about the value in the parameter and also sample data in the table and so on.
    Regards
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Top N Group Sort

    Hi all,
    I have a report that does a group sort just to show the top 20. I've been asked to do one to show top 50.
    Rather than having two reports can I pass 20 or 50 as a parameter to the group sort? If so, how is this done?

    The 20 is currently set in the group sort expert.
    So ideally I'd like to pass 20 or 50 as a parameter to it but I can't see how to do this.

  • Group Sort on formula field

    I am using CR Professional 11.5 on Windows XP/Progress platform.
    I have a formula field that calculates the GM% on the Employee Group Footer level and want to sort the employees in descending order by GM%.  I have gone in circles trying to calculate this field differently in order to be able to perform a Group Sort but this GM% cannot be summarized, which would allow me to use the Group Sort Expert.
    The fact that GM% is used in businesses world-wide each and every day makes this unbelievable that it should prove to be this difficult.  Is there something that I am missing as a newbie to CR design? 
    Any help provided is greatly appreciated!
    Marlene Human

    That's so awesome!  If only I knew how to use sql commands!  Everytime I try to create one it has errors that I dont' understand.  Do you know of a site for sql syntax that might help me to do this?  I have looked and can't find what I need to make this happen.
    So what I need to do is to use 'Formula Workshop' and create a new SQL Expression Field?  Using the formula above, how would this look in SQL?
    Thank you so much for your help...I am so grateful!!!  I have been working on this for months and keep hitting this snag.  I first started out using a cross-table and got confused because you can't summarize the GM% so I then changed the summary to 'weighted average of GM% with Tech/Rev' so that helped, but the Total per Employee has been keeping me stumped. 
    Thanks again.

  • Group/Sort Summary Totals for Duration % Complete not working

    Hello, I'm new to this forum and have used p3 off and on years ago and had some exposure to p5, my background is more toward Project Controls - Cost management rather than scheduling. Here is my issue/question: I was told by the PM not to baseline the schedule (I know, I should have but I didn't, I did as I was specifically requested), that is a topic for another day, however. I am trying to understand the process of the % completes on my resource loaded schedule which all activities are set to duration percent complete. The schedule has roughly quarter of the activities which have been actualized, but my issue is with the "Summary Totals" of the duration % complete when I select that option in the Group/Sorting. All of the activities in a group for example will show 0% complete but the Summary Total of those activities will show greater than 0% or some of the activities duration % completes show a value greater than 0% but the Summary Total of those activities show 0%. What is causing this and why are they not consistent? Any help is greatly appreciated!
    Shannon

    I'm currently showing the duration % complete with a renamed label. The total is not rolling up to the summary. I've also discovered that the unit % complete is not calculating correctly too I believe. For example: I have 3708 budgeted hours and have expended 656 hours and the Unit % Complete is showing 19.08% when I would have thought that the % would have been calculated based on Actual Units (656) / Budgeted Units (3708) totaling 17.69% not 19.08% which it is showing. I cannot find in the reference manual how the percent completes are calculated for units nor in the help section of the software itself either. An explenation would be greatly appreciated!
    Shannon

  • Group sort using 2 fields

    Is there any way that I can have two fields as a group sort in order that the first group sort field will repeat when the second field changes?
    Thanks.
    Leah

    One possibility would be to create a calculated item (ItemA||ItemB), and use that as a hidden group sort. Not sure about your platform, but in Desktop, you need to specify the item as a 'group' sort, then change it to 'hidden'. You would still display your original items, but don't sort on them.

  • Group Sort Option

    I have a formula on a group level.  That is in basic sum(x)-sum(y)/sum(y).
    I need to use this as a group sort option and it does not seem to allow me to

    Hi Brian,
    In order to sort with the result of sum(x)-sum(y)/sum(y) use the group sort order based on sum(x). Since we cannot sort on the result of the formula that contains summaries.
    Thanks & Regards,
    Raghavendra.G

  • Group Sort Filtering

    Hi
    I have a report which has a group sort on number of days sickness leave for employees over a period of a year .
    Is there a way of setting a condition on the group (sub) total to exclude total sickness less than 8 days and the individual lines that make up the sub total?
    Or could you advise of an alternate way to do this.
    So to recap I need to exclude employees whose sickness total for a year is less than 8 days.And the report lists individual entries of sickness for a year by employee.
    I am using Discoverer Desktop version 4.
    Thanks
    Edited by: user650649 on 23-Jul-2010 02:28

    Hi,
    In general, you can do this by using an analytic sum function in a calculation. So you would calculate the total number of days sickness partitioned by the employee and the year. You can then include this calculation in a condition to exclude all the records where this total is less than a given value.
    Regards,
    Rod

  • Group sort

    Hi
    I have a date field and i did a group sort on that feild, for some reason its not giving me the months in order.For example
    the result must be like below
    JAN 08
    FEB 08
    MARCH 08
    APR 08
    Instead its showing
    MARCH08
    JAN08
    APRIL 08
    FEB 08
    please any advice will be of great help.
    Thanks

    You can display the data any way you want, but if you sort on a date that is in a "Month, Year" format, they will sort alphabetically. You need to sort on the numeric month to get things to display in standard calendar order.
    Show the date as you want, but sort on a calculation that uses the numeric month (and do not sort on the date being displayed). When setting up the sort, check the "Hidden" box, and the column will not be displayed.

  • Group by Parameter

    Is it possible to group by Parameter?  If so how?
    What I'm trying to accomplish is the following:
      I have a main report that is basically a list of totals from many subreports
      The common denominator is the JobCode
      I'd like to run the main report for several JobCodes, which I've set up as a Dynamic, Multi-Select Parameter, which is the link between the subs and main.
    The report works great if I select only one JobCode; however, whenever I select more than one JobCode, only the first one I select displays.  I've got the main report grouped by JobCode with the subreports in GH1 and the desired totals in the GF1.  I've tried a varied number of configurations none of which work as desired.
    Any ideas or am I stuck running a separate report for each JobCode?
    Thanks much in advance!

    The data source is a database called NexGen with many tables. 
    My main report's selection criteria is simply field = parameter (exactly ... {FMS_JOB_MASTER.JobCode} = {?Job Code}).  The Parameter is a multi-select, dynamic parameter.
    The 5 fields on the main report are pulled from one table and one view and all the subreports are pulling also from tables/views ... some separate tables ... some same, but with different selections criteria.  Some of the subreports have more than one table so as to include the JobCode in order to tie with the main database. 
    Main Report -- There's one field from a view displayed.  The view is joined to the main table as Left Outer Join.
    SubReports -- Linked to Main Report by Job Code parameter and the select data in subreport bases on field is JobCode.  In each subreport I've placed the jobcode parameter in the report header and each subreport has ?jobcode in the selection criteria among potential other selection criteria necessary for a given subreport.
    The other issue I'm having for some reason is that only one of my JobCodes will display ... even when I select just one different JobCode the next time I go to view the report.  Yes, all the JobCodes have data.
    There was one time I was able to pull up two JobCodes at once like I'd like; however, the data was all messed up ... incorrect.
    I may just resort to printing data for one JobCode per main report.
    If there's a simple solution, please let me know ... otherwise I'll do just one per report.
    Thanks!

Maybe you are looking for