+ Reply to Thread
Results 1 to 2 of 2

How to pivot a data set (or use formulas) and add columns based on criteria

  1. #1
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    How to pivot a data set (or use formulas) and add columns based on criteria

    Hallo. I have this data set with SKU, dates, purchase quantity, and a price per unit. Attached in first tab on left.

    I want to be able to create an output with these rules but I don't know how to do it.

    Rules and Output:
    I want one row per sku (in the data set, there is one row per purchase date, per sku).

    If there is one purchase date for a sku, then that row can just be presented as is.

    If there are more than purchase dates for a sku AND the average price is the same, then I just need one row that sums quantity and keeps average price the same.

    If there are more than one purchase date for a sku, AND the average prices are different, then I want those separated in THE COLUMNS. So it would be like this
    SKU, Purchase Quantity, Price per unit, purchase quantity, price per unit, etc (the dates don't need to be specified but it does need to be in order of date.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,562

    Re: How to pivot a data set (or use formulas) and add columns based on criteria

    It looks as if the table in columns I:S on the Base sheet is supposed to be an intermediary between the table in columns A:G and the table in columns A:E on sheet2. That being the case I didn't write any formulas for transferring data from columns A:G to columns I:S instead writing formulas, as well as rearranging the first table so that data from the first table transfers directly, with the aide of helper columns (which may be moved and/or hidden for aesthetic purposes).
    The helper columns headed 2016 Sales and 2017 Sales are populated using the formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The helper column headed Count is populated using: =COUNTIFS(A$4:A4,A4)
    On sheet 2 the COGS columns are populated using the array entered formula*:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    *Array entered formulas are confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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: 2
    Last Post: 09-13-2017, 01:55 AM
  2. Hide pivot table columns based on date criteria
    By boontz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-16-2014, 09:56 AM
  3. Macro to filter data and copy the data's from multiple columns based on the criteria
    By millatshawn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-22-2014, 08:14 AM
  4. formulas for search based on multiple criteria in multiple columns
    By oneworld in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-02-2013, 06:57 AM
  5. [SOLVED] sum data in pivot table based on date criteria
    By joeycrak in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-23-2013, 09:45 AM
  6. Code to hide columns based on date criteria and insert another column with formulas
    By RandiLee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2012, 11:04 AM
  7. Pivot multiple columns into rows based on criteria
    By vboz5 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-09-2012, 11:54 AM

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