Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subtotal Reporting (03)

    I have data that I would like to subtotal on each change in field (let's call it FIELD1) and sum on total cost. As an example each row contains either a fruit or vegetable in that particular field with no specific sort order.

    I know that in order for the subtotal feature to properly work the data should be sorted first on FIELD1 and then apply the subtotal to the data. My challenge is to maintain the original order of entry prior to the sort after removing the subtotals. I understand that another sort would be in order but was wondering if there was another approach.

    Thanks,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subtotal Reporting (03)

    You can apply subtotals on unsorted data, but you'll get a lot of subtotal lines:

    <table border=1><td>Product</td><td>Amount</td><td>Apples</td><td align=right>5</td><td>Apples Total</td><td align=right>5</td><td>Pears</td><td align=right>3</td><td>Pears Total</td><td align=right>3</td><td>Apples</td><td align=right>4</td><td>Apples</td><td align=right>2</td><td>Apples Total</td><td align=right>6</td><td>Pears</td><td align=right>6</td><td>Pears</td><td align=right>4</td><td>Pears Total</td><td align=right>10</td><td>Grand Total</td><td align=right>24</td></table>
    I probably don't understand what exactly you want to accomplish.

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subtotal Reporting (03)

    Hans,

    The intent is maintain the grouping therefore one total for apples and etc. I guess I will have to incorporate two sorts. The first to sort by FIELD1 and then another sort on another field such as LINE_NO.

    I thought there may be another approach but it does not look that there is.

    Regards,
    John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subtotal Reporting (03)

    I'm afraid you're correct. Or provide the totals for apples, pears etc. elsewhere, for example in a pivot table. The source data for a pivot table don't have to be sorted.

  5. #5
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    268
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Subtotal Reporting (03)

    You could use a pivot table, as Hans suggests, or use an array formula or DSUM function to calculate the total for rows that meet a given criteria (ie, the 'type' column = "pears," "apples," "oranges," etc). If you prefer to use subtotals on sorted data, you should insert a new column with values of 1,2,3,4, incrementing for each row. After sorting by "type" and applying subtotals you can remove the subtotals and re-sort in this key number sequence to restore the original order.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •