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.

Similar Messages

  • 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.

  • Grouping by a concatenated field?

    I have a report with 1 group and 3 additional sort fields. What I'd LIKE to do is have a single field that I add all the sort fields into, to create a single field, and then group by that. So that any time any of the elements of that field change, it triggers the group change. For example:
    Group on: FIELD1
    Sort on: FIELD2, FIELD3, FIELD4
    Goal:
    Build a single string, MyStr := FIELD1 + FIELD2 + FIELD3 + FIELD4
    Remove all groups and sorts, then group on that formula field.
    Can that be done, and if so, can someone point me in the right direction?
    Thanks a million! You guys are really helping me get this project off the ground.
    (CR2010)
    ETA: Though this sounds ridiculous, this particular report would benefit greatly from this methodology. Long story (sigh).

    On another thread I posted this morning, I asked for assistance with creating a string in which multiple Hard Drive capacities were placed (i.e. "500G, 1T, 2T", etc) and only displayed when the group changed. While that worked well, there are SIX total group/sort fields. I would really like to combine all those into a single string, group on that, and insert the formula when the group changes. It seems easier than trying to manage so many fields. If I want to keep them individual, I have to change them all to Groups, because when any ONE of those fields changes (and yes, the are in order of frequency-of-change), I'd need to display a line of data that would include the capacity string.
    The detail section would be entirely suppressed.
    It just seems that it would be easier to have a single group to manage, rather than a group plus 4 or more sort fields.

  • Formula Field Sorting

    Frield 1 is group on Date (Group1)
    Field 2 is group on workstation (Group 2)
    Field 3 is a formula field Sum(Amt).
    The Report will look like below when displaying the Group Footer #2 (workstation) line.
    Date           Workstation    Amount
    11/01/2010        A             2,550
    11/01/2010        B            55,000
    11/03/2010        D            78,200
    11/04/2010        C              5,500
    I would like to report to be sorted in decending order on the Amount field which is a formula field.
    Date           Workstation    Amount
    11/03/2010        D             78,200
    11/01/2010        B            55,000
    11/04/2010        C              5,500
    11/01/2010        A              2,550
    The Group Expert does not list the formula field as a field that can be grouped on. How can this be done?

    Hi
    I have a similar issue....
    I have a report that's looking for Turnbacks,Total Trips and Turnback Percent of total trips grouped by Vendor.
    Report Layout
    Date (Group1)
    Vendor (Group2)
    Under group Vendor I have summarized fields...
    Date 20101119
    Vendor Id         Sum of Turnbacks         T otal Trips                      Turnback Percent of total Trips
    123                   50                                  100                                       50%
    456                  10                                  100                                       10%
    789                  100                                100                                       100%
    Date 20101120 
    Vendor Id         Sum of Turnbacks         Total Trips                          Turnback Percent of total Trips
    123                   60                                  100                                         60%
    456                   20                                  100                                         20%
    789                  100                                100                                         100%
    I would like to sort the  Turnback Percent of total Trips field in descending order. But it does not appear in neither(Group or Record) sort option.
    Any help will be greatly appreciated.
    Thanks!

  • How to sort groups by derived formula

    My report contains two groups. First grouping is by department and second group is by pay_code (for example, OT, OT1, OT5 are overtime paycodes and RG, RG1, RG5 are regular hour paycodes). Each group at the department level contains a running total of overtime and regulartime wages (wage_amount is a database field for each record). I've inserted a formula in the department group footer: runningTotalOvertimeWages/runningTotalRegularTimeWages.
    There are about 70 department groups however I only want to show the 10 departments that have the highest overtime rate (result of formula described above.) I've read the docs for the Group Sort Expert however this option is not enabled because I'm using running totals and not summaries. Using a summary instead of a running total doesn't produce expected results (because second group is defined conditionally based on value of paycode.)
    Is there another approach I can use?

    Hi Patricia,
    I agree...the summary feature is has too many holes in it. 
    -What I mean is, can you add (sum...) the groups' overtime in a formula like: @sumOT  numbervar holdT:= holdT + table.ot.
    Running Total is good because it gives you some nice options and a place to set formulas.
    -If none of this is good for you, then I would go to the query
    (actually, this is the best solution anyway).
    Each db has it's own way of saying "Give me the top n of records". Here's a few ways of doing it:
    http://blogs.claritycon.com/blogs/satish_vemula/archive/2006/02/15/220.aspx...so get the top 10 groups in the query.
    ...then you can group by sum(ot) in the query.  This will give you the 10 groups and the sums (in whatever order you like).
    Please forgive me if I'm off track with what you're saying.  Not trying to frustate...your second posting did make things a little clearer.
    Hope this helps,
    The Panda
    I just wanted to add that in my "DB2" world, I might use a "With" statement
    to create a temp table with the original query, do all the calculations with the
    "with" table, and output everything preprocessed to the report.  This is great for charts and such where placement is so limiting in Crystal(...all the calculations are "below me", yet I want to show the chart "above me", etc.)
    Edited by: pandabear on Jun 23, 2008 3:37 PM

  • Is it possible to do sorting on multiple field inside a GROUP

    Hi
    I am wondering if it is possible to do a multiple sorting on multiple column/fields?
    When I right click on Change Group on the report
    on the "Change Group Options" window, it only has one field which allow you to sort in ascending/ descending order.
    I notice that it also has another checkbox which called Use a formula as Group Sort order, I am not quite sure how to use it to sort multifield/column.
    E.g.
    I have a table which has 5 fields
    I would like to sort it by TotalSpend, TotalEarned, Department, ...etc
    I would be grateful, if you can show me how to do a group sorting for multi column/fields
    Thanks in advance.

    To Sastry,
    Thanks for your information, unfortunately, I am using Crystal report XI.
    To Sandra,
    <<Yes, go into the Group expert and select them in the order in which you want them sorted>>
    Do you mean create different group to do the sorting?
    Could you show me how to create a formula which allow crystal report to do the sorting on multi-field.
    Thanks in advance.

  • The formula field is not sorting both ascending and descending

    Dear All,
                   I am designing scoreboard the net amount contains the formula field, i sorted with asceding order by using sort,but it is not sorted both ascending or descending ,
                  Suppose if i used to sort the database field it is sorted properly  so any one help me very urgent
    Regards
    Selva.D
    Edited by: Rui Pereira on Aug 8, 2008 11:32 AM

    Dear Suda,
                     The scoreboard i designed via query print layout. So i calculated  by using formula field ie totalsales- sales return for that i used formula and i follow the below steps
    Choose repetitive area -
    > Right mouse click---> sort
    in the sorting i choose the formula uinque id and i choose Ascending then summary, after i click ok
    Suggest me the solution
    Regards
    Selva.D
    Edited by: Rui Pereira on Jul 8, 2008 5:18 PM

  • Sorting on a Formula field

    Everytime I try to do a sort on the formula field below, I can't sort on the field.  It doesn't even show the field in the explorer window to sort on.  The formula is below.
    Sum ({fct_CurrentSales.Cases}, {@upc}) /
        (tonumber(Maximum ({vw_dim_Product.CA_MPN_JMelBoxesPerPallet}, {@upc}))) / {Command.Previous Fiscal Month}

    Sorting is done at record level and you're using a sum in your formula as well as a maximum value.  Not sure about what is being done in the {@upc} formula but it may be affecting it as well.
    Look at your user guide and look up the multiple passes CR makes and what is done in each pass.
    (I used to keep a copy of the multiple pass flowchart on the wall above my computer as it contains good information on what can be done and when during the report generation.)
    Sum ({fct_CurrentSales.Cases}, {@upc}) /
    (tonumber(Maximum ({vw_dim_Product.CA_MPN_JMelBoxesPerPallet}, {@upc}))) / {Command.Previous Fiscal Month}

  • Group by one field but sort by another field

    I  need to create a Parent directory for our school.
    I group the report by last name, then by family ID. Some data example below:
    Family -grade school        |     Guardians                                      |        Address                         |              Phone
    Abraham
    Callum  Grade 8               |      Jenniifer and Brian Abrham            |       21 Lake str.....                  |                 756-111-1111
    Abzug                                   
    Nathen grade 6                 |     Shari and Paul Abzug                     |        111  knob  hill                |                    620-126-4555
    Julie     grade 7                      
    It looks fine, but then we found a little defect.
    For famly that has the same last name, we want it also sort by first name for example:
    Johnson
    Charles Gr.11             |       Richard and Maureen Johnson           |        210 brown lane...          |            000-000-0000
    Johnson
    Madeline Gr.11            |    David and Carol Johnson                        |            .................                 |                  ...............
    Johnson
    Duncan Gr.09           |               .Mark and Patti Johnson               |           .....|............                                  
    We would like above 3 records , group/sorted by lastname, which is fine, then  group by family ID, but sort by first name.But you can say the first name is not sorted right.
    HOw can I group by familyID, but sort by first name.  I tried to use family ID sort by original order, then add a sort record by first name,  but that not works for me.It only sort the sub data set by first name instead of sorting the group by first name.
    Any help would be appreciated.
    Thanks
    Ann

    Sorting by Lastname&familyID isn't going to do anything for you that familyID isn't already doing by itself. The reality is that you aren't going to get exactly what you want without being able to attach the first name of of the person in each family with the highest ranking sorting value and attach it to each record within the respective families.
    For Example... IF you want
    FamilyID     LastName     FirstName
    1001          Jones          Zack
    1001          Jones          Bob
    1001          Jones          Mark
    1001          Jones          Tony
    1002          Finch          Steve
    1002          Finch          Scott
    1002          Finch          Anthony
    1002          Finch          Bill
    1003          Jones          Christopher
    1003          Jones          Judy
    1003          Jones          Sarah
    1003          Jones          Amy
    To look like this...
    FamilyID     LastName     FirstName
    1002          Finch          Anthony
    1002          Finch          Bill
    1002          Finch          Scott
    1002          Finch          Steve
    1003          Jones          Amy
    1003          Jones          Christopher
    1003          Jones          Judy
    1003          Jones          Sarah
    1001          Jones          Bob
    1001          Jones          Mark
    1001          Jones          Tony
    1001          Jones          Zack
    You'll need to start with something like this...
    FamilyID     LastName     FirstName     GroupSortKey
    1001          Jones          Zack          Bob1001
    1001          Jones          Bob          Bob1001
    1001          Jones          Mark          Bob1001
    1001          Jones          Tony          Bob1001
    1002          Finch          Steve          Anthony1002
    1002          Finch          Scott          Anthony1002
    1002          Finch          Anthony          Anthony1002
    1002          Finch          Bill          Anthony1002
    1003          Jones          Christopher     Amy1003
    1003          Jones          Judy          Amy1003
    1003          Jones          Sarah          Amy1003
    1003          Jones          Amy          Amy1003
    Then you can sort on LastName > GroupingKey > FirstName And Get this
    FamilyID     LastName     FirstName     GroupingKey
    1002          Finch          Anthony          Anthony1002
    1002          Finch          Bill          Anthony1002
    1002          Finch          Scott          Anthony1002
    1002          Finch          Steve          Anthony1002
    1003          Jones          Amy          Amy1003
    1003          Jones          Christopher     Amy1003
    1003          Jones          Judy          Amy1003
    1003          Jones          Sarah          Amy1003
    1001          Jones          Bob          Bob1001
    1001          Jones          Mark          Bob1001
    1001          Jones          Tony          Bob1001
    1001          Jones          Zack          Bob1001
    I don't see how you'd be able to do that without using SQL.
    HTH,
    Jason

  • 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

  • Changing group sort programmaticaly

    Is there a way to change or create a "group sort" formula from vb.net 2005? I am using Crystal reports XI R2.
    I need to be able to sort by ItemID, Qty, Amount or Volume, create the sort formula and be able to change the sort direction also.
    I tried to use:
                Dim crSortField As SortField
                Dim fieldDef As DatabaseFieldDefinition
                For Each crSortField In cr.DataDefinition.SortFields
                    fieldDef = cr.Database.Tables(0).Fields(crSortField.Field.Name.ToString)
                    crSortField = cr.DataDefinition.SortFields(1)
                    crSortField.Field = fieldDef
                    crSortField.SortDirection = SortDirection.DescendingOrder
                Next
    I get an error that says: The sort is not defined in the data definition.
    Any help would be appreciated.

    Here is a sample I had kicking around.
    Keep in mind that you must have at least one sort already set up to be able to change it. Otherwise you'll need to use the RAS SDK to add sorts at runtime.
              private void Form1_Load(object sender, System.EventArgs e)
                   ConfigureCrystal();
              private void ConfigureCrystal()
                   // Instantiate and load the Sort Report.rpt
                   crReportDocument = new ReportDocument();
                   crReportDocument.Load(Application.StartupPath + "\\..\\..\\Sort Report.rpt");
                   // Change the sorting for the group to sort based on the summary
                   // of @Order Amount x Tax.
                   SortFields crSortFields = crReportDocument.DataDefinition.SortFields;
                   foreach(SortField crSortField in crSortFields)
                        if (crSortField.Field.Name == "Count ({Orders.Order ID}, {Customer.Customer ID})")
                             // Get the new field to sort on
                             FieldDefinition crFieldDefinition = crReportDocument.DataDefinition.SummaryFields[1];
                             crSortField.Field = crFieldDefinition;
                             crSortField.SortDirection = SortDirection.DescendingOrder;
                             break;     // break out of the foreach loop
                   // Change the sorting for the record type as well
                   foreach(SortField crSortField in crSortFields)
                        if(crSortField.Field.Name == "Order ID")
                             FieldDefinition crFieldDefinition = crReportDocument.Database.Tables[1].Fields[1]; // the Order Amount in in the 2nd table and 2nd field
                             crSortField.Field = crFieldDefinition;
                             crSortField.SortDirection = SortDirection.DescendingOrder;
                             break; // break out of this foreach loop
                   // Set the ReportSource of the CrystalReportViewer control
                   crystalReportViewer1.ReportSource = crReportDocument;
              private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
                   // clean up
                   crReportDocument.Close();
                   crReportDocument.Dispose();
                   crReportDocument = null;

  • Parameter-driven group sorting?

    Post Author: craibuc
    CA Forum: General
    i have a report that is grouped by employee name.  the report has 7 columns, displaying a summarized field in the group header.  the summarized values are based on formulae that are evaluation in the Details section.i would like to be able to dynamically sort the group based on a parameter value.  the parameter would allow the user to sort either on one of the week days or on the employee name.in the past, i have been successful sorting the Details section based on a parameter, but sorting a group is challenging. has anyone been able to do this?

    Post Author: Charliy
    CA Forum: General
    If you want to do Parameter driven grouping:  You have a formula:  IF {?GroupBy} = 1 THEN {table.EmployeeName} else IF {?GroupBy} = 2 THEN {table.SomethingElse}
    You may have to use Totext or some other function to make them the same data type.  Group on that formula.  If one of the options is something like day of week, or a date or portion of a date (YYYYMM), then create another formula for display in the group header.
    IF you're talking about sorting within a group -  same formula, you just use the sort expert to put it after the grop field in the sort sequence

  • How to create a group with multiple data fields

    Post Author: RichS
    CA Forum: Formula
    Using CR XI.  Using CSV input from ODBC text driver.  No problems here.
    There are 3 fields that I want the same group by action.  Is this possible?) 
    If any one of these 3 fields change I want some header information and column fieldnames to display.  The header information I only want displayed on the first page (on the change) and the column fieldnames to display on every page.  I have played around with things like "InRepeatedGroupHeader" and "report group header on each page".  I am not getting all the results that I am looking for though.
    I want report to look like:
    Page header stuff  (to display on every page)  This data consists of some fields that will have static data and will display on every page.  And it consists of 3 non-static fields that I want to group on. 
    Group header stuff that I only want displayed on the first page on a change from one of the 3 fields mentioned above.
    Column headings that I want displayed on every page.
    Details data
    Group footer stuff (details not important for this)
    I get the expected output (column headings displayed on every page, and group header stuff display on the first page on each group change) with one group field.  But I want the group change to happen for all 3 fields.
    It seems simple but I can't find a way to create a "group" so if "field1 or field2 or field3" change, I get the same "group by" action.  I just need to know how to get the expected action.
    I expect that I might have some terms mixed up and/or some important information that would aide you in helping me.  If that is the case please re-post and I will add any missing or mis-stated information.
    Thanks,

    Post Author: V361
    CA Forum: Formula
    I am slightly confused, but perhaps you can create a formula
    Then group on the formula.  If this is not what you want, could you post some sample data, with the desired results.

  • Chart Expert - Why are some formula fields not available?

    I have a report where I had to do Running Totals with formulas.  Following what I learned long ago from the documentation, I laid in my formulas, and then setup some "Display" formulas to print out the results at the end of my report.
    Now I am adding a chart to show a sort of 'summarized' version of the report - its a simple Pie chart...
    But when I go into the Chart Expert and want to select those Display formula fields (there are 4 of them) - they do not appear in the list?
    FYI - These four Display formulas are in the Report Footer of the report, and my chart is in the Report Header. 
    Why do some of my formula fields appear in the Chart Expert "select field" list - while others do not?
    I checked the documentation on this, but it is very "lite" and does not indicate why this might be...
    Any help is most appreciated!

    Read again -  "Problem has been circumvented" NOT "worked around".  In other words, when you pay a fortune for a poorly documented piece of software and you are dependent on answers from a Forum, where at times no one answers your question(s) and your boss is shouting at you as to how you selected such a lousy piece of software with such "lite" documentation and is hardly going to pay any more money for a support call to answer a simple question that should have been covered (and then some) in the documentation, (let alone support of the problem) - you CIRCUMVENT, i.e. give up and find some other way to do what you were trying to do.
    Hence, problem circumvented, NOT worked around.
    Thanks for asking - here's 10 points for your efforts.

Maybe you are looking for