+ Reply to Thread
Results 1 to 5 of 5

Formula to return values from a spreadsheet with specific parameters

  1. #1
    Registered User
    Join Date
    02-09-2016
    Location
    Cambridge, England
    MS-Off Ver
    2013
    Posts
    2

    Formula to return values from a spreadsheet with specific parameters

    Sorry I don't know a better way to word this! I have attached a spreadsheet which shows an example of the data set I am looking at.

    I have data for a range of organisations split out into months. I am interested in getting the total value of each month for each organisation so I would like to be able to extract this data from the spreadsheet. No matter how I try I can't force a pivot table to give me this and was hoping I could perhaps write some code (eg everytime you see Jan-16 in a cell, return me the value directly under this (that will be the total) and also the value in the row below and two cells to the left (that will be the Organisation name).

    Anyway I think it's clearer if you look at the spreadsheet - anyone have any ideas of how I can extract the data I want?

    Thanks!

    Caz
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Formula to return values from a spreadsheet with specific parameters

    Hi,

    Your data does not lend itself to a Pivot Table. I've reformatted it in the attached sheet and added a PT for you. I've also added a normal table with SUMIFS() formulae which contains the same results. A PT is IMO much to be preferred since it's far more flexible and can be diced/sliced in any way you could conceivably want.
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-09-2016
    Location
    Cambridge, England
    MS-Off Ver
    2013
    Posts
    2

    Re: Formula to return values from a spreadsheet with specific parameters

    Hi,

    Thanks for your reply. Unfortunately despite the fact that your format is ideal for what I want to do, the report I pull is in the format I sent previously. It's an industry format report so we can't change the format for how the output looks - but I am hoping that I can strip out relevant data so that I can do a bit more intelligent analysis of it. I'm very interested in seeing the customer with their totals you see so I need to know how to extract this data from the report as it is in the original format.

    Any ideas?

    Thanks.

    Caz

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Formula to return values from a spreadsheet with specific parameters

    Hi,

    A report not being in the right format for a PT is a common occurence. The answer usually is to have a pre-processing macro that reformats the data you are presented with into a format a PT can use. In your case it's fairly straightforward. The steps you need to take are

    1. On a new sheet create the 4 column headings, Date, Organisation, Day, Amount
    On a new sheet copy the values from A6:Bnn to the next available cell in column B on the new sheet
    2. Copy the C2:Cnn values from your data to C2 on the new sheet
    3. Fill the range A2:Ann with the dates from the data column C header

    If there is data in the next column D repeat steps 2 & 3 above.

    4. Finally filter the new data for rows that are either blank in column A or contain the text "Totals" and delete these rows.

    You then have the source data for a PT. Try using the macro recorder to create a macro to do it. That will give you a good starting point. The code it produces will need editing to replace hard coded cell addresses. But when you're at that stage post back and no doubt we'll be able to develop it further.

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Formula to return values from a spreadsheet with specific parameters

    Add column headers like this to your existing data so you have an arrangement like this:
    A
    B
    C
    D
    4
    Organisation Weekday
    Jan-16
    Feb-16
    5
    Totals
    42
    11
    6
    Organisation 1 Tuesdays
    17
    2
    7
    Organisation 1 Wednesdays
    15
    5
    8
    Organisation 1 Thursdays
    10
    4
    9
    10
    Jan-16
    Feb-16
    11
    Totals
    157
    49
    12
    Organisation 2 Tuesdays
    23
    11
    13
    Organisation 2 Wednesdays
    89
    15
    14
    Organisation 2 Thursdays
    45
    23
    15
    16
    Jan-16
    Feb-16
    17
    Totals
    39
    10
    18
    Organisation 3 Tuesdays
    15
    5
    19
    Organisation 3 Wednesdays
    14
    4
    20
    Organisation 3 Thursdays
    10
    1


    Row 4 shows titles for each column.

    Select all the data including row 4 with the headers. Click on the Insert tab, Pivot Table
    Drag Organization to the row labels box, and the dates to the Values box. Change the Value Field Settings for each of the dates from Count to Sum.

    With the Row Labels filter, deselect Totals and Blank. Change the column headers of the pivot table to suit.
    Result:
    A
    B
    C
    3
    Organization Jan-16 Feb-16
    4
    Organisation 1
    42
    11
    5
    Organisation 2
    157
    49
    6
    Organisation 3
    39
    10
    7
    Grand Total
    238
    70
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 02-23-2015, 12:28 AM
  2. Return if an item is late based on start and end times and specific parameters
    By d2thep in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 04-10-2014, 10:25 AM
  3. What formula to use to count specific parameters within a cell
    By Ecopower in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-20-2013, 11:24 PM
  4. Return specific values from one workbook to another, in specific cells
    By Bobbie12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2013, 03:33 PM
  5. [SOLVED] Need Several Values to Line up to return a specific value - need formula help, please!
    By ImHorhay in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-18-2013, 05:10 PM
  6. Return a value within specific parameters
    By ezdizzy in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 10-08-2009, 06:39 PM
  7. Replies: 5
    Last Post: 05-26-2009, 06:36 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1