+ Reply to Thread
Results 1 to 22 of 22

Creating a pivot table using aggregate counters and flags

  1. #1
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Creating a pivot table using aggregate counters and flags

    Hello,

    See the attached workbook:

    I can use assistance from the group here in building the below from my sample data.

    I need to accomplish a few things here and can use assistance:
    - Create a VLOOKUP to count the number of matches with the below criteria.
    In “Sheet 1” compare the value in Column H to the “List” tab (Column A). When the value in Column H matches (regardless of case) to the “List Tab”, AND Column I = “Reformat” output a ‘Y’, else a ‘N’ in Column J.
    In “Sheet 1” compare the value in Column H to the “List” tab (Column A). When the value in Column H matches (regardless of case) to the “List Tab”, AND Column I = “Select1” OR “Select2” output a ‘Y’, else a ‘N’ in Column K.
    In “Sheet 2” compare the value in Column H to the “List” tab (Column A). When the value in Column H matches (regardless of case) to the “List Tab”, AND Column I = “Reformat” output a ‘Y’, else a ‘N’ in Column J.
    In “Sheet 2” compare the value in Column H to the “List” tab (Column A). When the value in Column H matches (regardless of case) to the “List Tab”, AND Column I = “Select1” OR “Select2” output a ‘Y’, else a ‘N’ in Column K.

    - Create a counter to aggregate the number of “Y’ values when Column A has the same value.
    In “Sheet 1”, when Column A has the same value, count the number of values = “Y” in Column J, and aggregate that number in Column L.
    In “Sheet 1”, when Column A has the same value, count the number of values = “Y” in Column K, and aggregate that number in Column M.

    - Create a Pivot Table to show the results.
    See the “Results” Tab. I need to display a unique list of Column A from BOTH tabs (Sheet 1 and Sheet 2). I should display Column D, and then the aggregate counters from Column L and M from the above calculations. I need this to be a pivot so that I can click on the value to see what values from Column H matched.

    Thank you in advance!!
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Good Morning everyone, just wanted to see if anyone can assist with my questions.!!!!

  3. #3
    Valued Forum Contributor mahju's Avatar
    Join Date
    11-27-2010
    Location
    Pakistan, Faisalabad
    MS-Off Ver
    Excel 2010 plus
    Posts
    730

    Re: Creating a pivot table using aggregate counters and flags

    Hi
    Try this one

    in sheet1

    in J2
    Please Login or Register  to view this content.
    and in K2

    Please Login or Register  to view this content.
    Copied down as needed

    Write the formulae on the same line for sheet2

    Regards
    Mark the thread as solved if you are satisfied with the answer.


    In your first post under the thread tools.

    Mahju

  4. #4
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Thank you! At first glance, this appears to work for Column J and K for Sheet1 and Sheet2.

    How would I do the next steps?

    - Create a counter to aggregate the number of “Y’ values when Column A has the same value.
    In “Sheet 1”, when Column A has the same value, count the number of values = “Y” in Column J, and aggregate that number in Column L.
    In “Sheet 1”, when Column A has the same value, count the number of values = “Y” in Column K, and aggregate that number in Column M.

    - Create a Pivot Table to show the results.
    See the “Results” Tab. I need to display a unique list of Column A from BOTH tabs (Sheet 1 and Sheet 2). I should display Column D, and then the aggregate counters from Column L and M from the above calculations. I need this to be a pivot so that I can click on the value to see what values from Column H matched.

  5. #5
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Good Morning!Anyone with the second portion of this? Thank you in advance, everyone is always so helpful!
    Last edited by bdav1216; 03-02-2017 at 09:40 AM.

  6. #6
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Morning check for any assistance on the 2nd part of my questions.

    Thank you!

  7. #7
    Valued Forum Contributor mahju's Avatar
    Join Date
    11-27-2010
    Location
    Pakistan, Faisalabad
    MS-Off Ver
    Excel 2010 plus
    Posts
    730

    Re: Creating a pivot table using aggregate counters and flags

    In Sheet1 , L2

    Please Login or Register  to view this content.
    In sheet1, M2

    Please Login or Register  to view this content.
    Hope this will work

    Regards

  8. #8
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    One issue with the above formula.

    In 'Sheet2', Column A has the same value (103990). I would need that counter (Column L and M) to account for the aggregate instances of 'Y' Values.

    So, as an example, since Column A in sheet2 has the same value (103990) and Column H returned a 'Y' value in both columns, I would like to see a value of '2' returned instead of 1.

    How would I create a pivot table (see 'Results' tab) that accounts for both Sheet1 and Sheet2?

  9. #9
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Any feedback on my above questions (and the pivot table using two sheets)?

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

    Re: Creating a pivot table using aggregate counters and flags

    Going back to post #1:
    In “Sheet 1” compare the value in Column H to the “List” tab (Column A). When the value in Column H matches (regardless of case) to the “List Tab”, AND Column I = “Reformat” output a ‘Y’, else a ‘N’ in Column J.
    Looking at the file attached to that post, on sheet 1, cell J5 is marked 'N' although hi02s is found in the 'List' and I5 displays 'Reformat'
    Supposing that to be an error the following formula displays the same answers in all other cases:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    As to a formula for column K the instructions say to find the terms 'Select1' or 'Select2' in column I, however the term used in sheet 2 is 'Selection' so should the formula attempt to find only 'Select' or should the formula attempt to find a term with 'Select' included?
    I'll wait to get some clarification before proceeding.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  11. #11
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Quote Originally Posted by JeteMc View Post
    Going back to post #1:
    In “Sheet 1” compare the value in Column H to the “List” tab (Column A). When the value in Column H matches (regardless of case) to the “List Tab”, AND Column I = “Reformat” output a ‘Y’, else a ‘N’ in Column J.
    Looking at the file attached to that post, on sheet 1, cell J5 is marked 'N' although hi02s is found in the 'List' and I5 displays 'Reformat'
    Supposing that to be an error the following formula displays the same answers in all other cases:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    As to a formula for column K the instructions say to find the terms 'Select1' or 'Select2' in column I, however the term used in sheet 2 is 'Selection' so should the formula attempt to find only 'Select' or should the formula attempt to find a term with 'Select' included?
    I'll wait to get some clarification before proceeding.
    Let us know if you have any questions.
    Correct, that was a mistake on my part; the formula should look for Select1 or Select2. Thank you for pointing that out.

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

    Re: Creating a pivot table using aggregate counters and flags

    That being the case a formula that will work for column K is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I now have another question. The next instruction states: In “Sheet 1”, when Column A has the same value, count the number of values = “Y” in Column J, and aggregate that number in Column L. Can we assume that it means the same value for the same customer?
    Let us know if you have any questions.

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

    Re: Creating a pivot table using aggregate counters and flags

    I am going to go ahead and assume the answer is yes, in which case the following formula could be used for columns L:M
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Paste the formula into L2,drag down to L8 then across to M8.
    We'll have to look into the possibility of a pivot table getting data from two sheets (tables).
    Let us know if you have any questions.

  14. #14
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Quote Originally Posted by JeteMc View Post
    That being the case a formula that will work for column K is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I now have another question. The next instruction states: In “Sheet 1”, when Column A has the same value, count the number of values = “Y” in Column J, and aggregate that number in Column L. Can we assume that it means the same value for the same customer?
    Let us know if you have any questions.
    That's correct - Column A and Column D would have the same value for as long as Column A does not change.
    Although Column A has the same value, Column D could have the same Customer values repeated.

    For example:

    Column A has different values, but could (not in the attached example though) have the same Customer name.
    103,801
    103,801
    103,982
    103,982

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

    Re: Creating a pivot table using aggregate counters and flags

    So if I were to change Customer C to Customer A on sheet 1 that would set up the same scenario that you describe. I don't see any change in the values displayed in columns J:M. Is that as expected?

  16. #16
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Quote Originally Posted by JeteMc View Post
    So if I were to change Customer C to Customer A on sheet 1 that would set up the same scenario that you describe. I don't see any change in the values displayed in columns J:M. Is that as expected?
    Yes, that seems to be working as expected (changing Customer A to Customer C. As long as Column A is used to differentiate when Column C has the same value, this is working well from the testing.

  17. #17
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    My last question then is how to display this in the 'Results' tab.

    - Create a Pivot Table to show the results.
    See the “Results” Tab. I need to display a unique list of Column A from BOTH tabs (Sheet 1 and Sheet 2). I should display Column D, and then the aggregate counters from Column L and M from the above calculations. I need this to be a pivot so that I can click on the value to see what values from Column H matched.

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

    Re: Creating a pivot table using aggregate counters and flags

    As to the pivot table question I believe that the issue is that of a unique key that would need to appear on both sheets 1 and 2 and I don't see any. However, I have a work around that might be of interest. Look at sheet 3 and you'll see that it is populated by formulas so that it will update automatically as sheets 1 and 2 are updated, providing the formulas are copied far enough down. The two formulas for sheet 3 are:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The pivot table on sheet PT then uses the data on sheet 3.
    Note: To arrange the customer names in alphabetical order on the pivot table they need to be in the left column (primary key).
    Let us know if you have any questions.

  19. #19
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Quote Originally Posted by JeteMc View Post
    As to the pivot table question I believe that the issue is that of a unique key that would need to appear on both sheets 1 and 2 and I don't see any. However, I have a work around that might be of interest. Look at sheet 3 and you'll see that it is populated by formulas so that it will update automatically as sheets 1 and 2 are updated, providing the formulas are copied far enough down. The two formulas for sheet 3 are:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The pivot table on sheet PT then uses the data on sheet 3.
    Note: To arrange the customer names in alphabetical order on the pivot table they need to be in the left column (primary key).
    Let us know if you have any questions.
    Thank you! I will try to use your suggestion on my larger data and will let you know should I have any questions.

    One minor update - for 'sheet 3', when there is no value, can you update the blank to a '0'?

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

    Re: Creating a pivot table using aggregate counters and flags

    Yes. Modify the second formula on sheet 3, which is applied to B1:N22 in the file attached to post #18, so that it reads:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Note: This will necessitate the need to filter out the zero in the 'Customer' column on the pivot table.
    Let us know if you have any questions.

  21. #21
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Creating a pivot table using aggregate counters and flags

    Quote Originally Posted by JeteMc View Post
    Yes. Modify the second formula on sheet 3, which is applied to B1:N22 in the file attached to post #18, so that it reads:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Note: This will necessitate the need to filter out the zero in the 'Customer' column on the pivot table.
    Let us know if you have any questions.
    For my previous question, I was referring to the counters in H and I (when blank, output a zero) only.

    One last question for now. and thank you for your time. Very helpful.

    Is it possible, in Sheet 3, to not display a row if both Column H AND I are = 'N'? The reason I am asking is my actual data will have many rows and I wouldn't need to review scenario's where both are equal to 'N'.

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

    Re: Creating a pivot table using aggregate counters and flags

    It requires a bit of setting up, however an advanced filter will work. First of all the rational is that if either column H result OR column I result is 'Y' then display that row. On sheet 3 A1 is 'Sheet'. Copy the headers from either sheet 1 or 2 into row one of sheet 3. The formula for sheet 3!A2 and down is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The formula for sheet 3!B2 (down and across) is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Sheet 3!P1:Q3 are the criteria for the advanced filter, notice that Q3 is hidden with the filter applied, however the formula in that cell is the same as in P2 (="=Y").
    From the Data tab, Sort & Filter pane, select 'Advanced' and you should see that the list range is $B$1:$N$22 and the criteria range is $P$1:$Q$3
    By the way, please don't quote entire posts when replying.
    Let us know if you have any questions.

+ 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. How to used pivot table to aggregate this request?
    By darbebo in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 07-05-2016, 01:44 PM
  2. Replies: 1
    Last Post: 07-29-2015, 05:19 PM
  3. Pivot Table disable aggregate sum, keep sum only? confused!
    By cesarmontoya in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-15-2013, 02:19 PM
  4. Creating Multi Condition Flags
    By bdparks in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-12-2013, 09:56 PM
  5. Excel 2007 pivot table does not aggregate properly
    By patrick23 in forum Excel General
    Replies: 0
    Last Post: 03-03-2011, 06:38 PM
  6. pivot table to aggregate values
    By excelism in forum Excel General
    Replies: 1
    Last Post: 07-13-2010, 08:54 AM
  7. "acessor flags" creating pivot table from recordset
    By Wolfie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2006, 04:45 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