Results 1 to 6 of 6

Thread: Formula for creating summary of vast data

  1. #1

    Formula for creating summary of vast data



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi

    I am not able to generate summary of below data:

    Group Fruits
    A Apple
    B Apple,Orange
    B Orange
    B Lemon
    B Apple,Lemon
    C Lemon,Orange
    C Lemon,Orange,Apple
    C Apple,Orange
    A Lemon,Orange
    B Apple,Lemon
    C Lemon,Orange,Apple
    B Apple,Lemon
    C Lemon,Orange
    D Lemon

    As per below format:

    Summary Apple Orange Lemon
    A
    B
    C

    Basically i want to know count of fruits held by groups.

  2. #2
    Excel 2010, Table, PivotTable
    No formulas, no code needed.
    http://www.mediafire.com/view/ld3l1n.../08_11_10.xlsx

  3. #3
    My data is not the way you presented. It is comma separated hence i found below solution

    Group Fruits A - Apple A - Orange A - Lemon B - Apple B - Orange B - Lemon C - Apple C - Orange C - Lemon
    A Apple,Orange 1 1 0 0 0 0 0 0 0
    B Apple,Lemon 0 0 0 1 0 1 0 0 0
    B Orange,Apple 0 0 0 1 1 0 0 0 0
    B Lemon 0 0 0 0 0 1 0 0 0
    B Apple,Lemon 0 0 0 1 0 1 0 0 0
    C Lemon,Orange 0 0 0 0 0 0 0 1 1
    C Lemon,Orange,Apple 0 0 0 0 0 0 1 1 1
    C Apple,Orange 0 0 0 0 0 0 1 1 0
    A Lemon,Orange 0 1 1 0 0 0 0 0 0
    B Apple,Lemon 0 0 0 1 0 1 0 0 0
    C Lemon,Orange,Apple 0 0 0 0 0 0 1 1 1
    B Apple,Lemon 0 0 0 1 0 1 0 0 0
    C Lemon,Orange 0 0 0 0 0 0 0 1 1

    =IF(A2="A",IF(ISNUMBER(SEARCH("*Apple*",B2)),"1",0),"0")

    In each cell i have entered above formula and for summary below formula

    Summary Apple Orange Lemon
    A 1 2 1
    B 5 1 5
    C 3 5 4
    Total 9 8 10

    =COUNTIF(D214,"1")

  4. #4
    Is there any other simple way. This task seemed simple but trick was comma in data.

  5. #5
    I was hoping you would see the "Text to Columns" transformation
    applied to your data.
    Doesn't require formulas for that either.

  6. #6
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,356
    Articles
    0
    Excel Version
    365
    Quote Originally Posted by Makjain View Post
    Is there any other simple way. This task seemed simple but trick was comma in data.
    I realise you wanted a formula, so this is just a bit of mucking about: Select the two column range, including headers (this last is a must) and run the macro below.
    First it copies the selected range to a new sheet to the right of the active sheet, then it does a text-to-columns then re-arranges that data to form a 2-column range on which it bases a pivot table which it adds to the new sheet and makes it the same as your summary table.
    Developed in Excel 2003, but if it falls over in later versions of Excel (I don't think it will) I can tweak it to work in those later versions.

    But how vast is vast?
    Code:
    Sub blah()
    Set myRng = Selection
    Set newsht = Sheets.Add(after:=myRng.Parent)
    With newsht
      myRng.Copy .Cells(1)
      Set NewRng = .UsedRange
      Set DataSecondColumn = NewRng.Offset(1, 1).Resize(NewRng.Rows.Count - 1, 1)
      DataSecondColumn.TextToColumns Destination:=.Range("B2"), DataType:=xlDelimited, ConsecutiveDelimiter:=True, Comma:=True
      lc = .UsedRange.Columns.Count
      On Error Resume Next
      Set Destn = .Cells(NewRng.Rows.Count + 1, 1)
      For i = 1 To lc - 2
        Set rngtomove = Intersect(DataSecondColumn.Offset(, i), DataSecondColumn.Offset(, i).SpecialCells(2))
        Set RngToMove2 = Union(rngtomove, rngtomove.Offset(, -rngtomove.Column + 1))
        RngToMove2.Copy Destn
        Set Destn = .Cells(Rows.Count, 2).End(xlUp).Offset(1, -1)
        rngtomove.Clear
      Next i
      On Error GoTo 0
      Set PTSource = .UsedRange.Resize(, 2)
    End With
    PTSource.Value = Application.Trim(PTSource.Value)  'trim spaces
    With ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=PTSource).CreatePivotTable(TableDestination:=newsht.Cells(4, 4), DefaultVersion:=xlPivotTableVersion10)
      .AddFields RowFields:=newsht.Cells(1).Value, ColumnFields:=newsht.Cells(1, 2).Value
      .PivotFields(newsht.Cells(1).Value).Orientation = xlDataField
      .RowGrand = False
    End With
    End Sub
    Last edited by p45cal; 2014-03-02 at 08:20 PM.

Posting Permissions

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