+ Reply to Thread
Results 1 to 5 of 5

Can I show the difference between 2 counted columns in a pivot?

  1. #1
    Registered User
    Join Date
    01-12-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    97

    Can I show the difference between 2 counted columns in a pivot?

    I have data that has rows of tickets. Each row has a year, a created date and a closed date.

    I am trying to create a pivot that shows the number of tickets opened in a year and closed in a year. This is done by just doing a count on the created date and closed date.

    What I would like to do is in the 4th column of the pivot, just simply subtract the count of created column with from the count of closed column. I can't figure it out though. I could do this calculation next to the pivot and off to the side but Id rather it be contained in the pivot.

    Thanks

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Can I show the difference between 2 counted columns in a pivot?

    There is a subtle "feature" of pivot tables: you can't do calculation on counts. While a count looks like it is a number, the pivot table can't handle it. Pivot tables work on a record-by-record basis and asking it to subtract one string from another or a number from a string or vice versa, just isn't going to work.

    The work-around is to resort to a helper column. Sometimes the formula is as simple as =1 as in the case where you might be doing a count of names. Every record has exactly one name. Other times it may be a bit more complicated such as =IF(ISBLANK(Closed Date),0,1).

    The helper columns "convert" the count into a value and values can be computed.

    Without seeing the source data, this is as far as I can take it.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    01-12-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    97

    Re: Can I show the difference between 2 counted columns in a pivot?

    Quote Originally Posted by dflak View Post
    There is a subtle "feature" of pivot tables: you can't do calculation on counts. While a count looks like it is a number, the pivot table can't handle it. Pivot tables work on a record-by-record basis and asking it to subtract one string from another or a number from a string or vice versa, just isn't going to work.

    The work-around is to resort to a helper column. Sometimes the formula is as simple as =1 as in the case where you might be doing a count of names. Every record has exactly one name. Other times it may be a bit more complicated such as =IF(ISBLANK(Closed Date),0,1).

    The helper columns "convert" the count into a value and values can be computed.

    Without seeing the source data, this is as far as I can take it.
    If I put in a helper column and had it be 1 whenever there was a date, would you then sum this in the pivot, taking the place of the count?

    If I have that correct, is there a way to get that subtraction calculation in the pivot?

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Can I show the difference between 2 counted columns in a pivot?

    Yes, use the sum of the helper column instead of the count of the original. You should have two helper columns: one for the created date and one for the closed date. Then use these in a calculated field.

    P.S. To get to the calculated field box, select the pivot table then select Analyze -> Fields, Items, Sets -> Calculated Field
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by dflak; 01-03-2019 at 06:11 PM. Reason: Add PS

  5. #5
    Registered User
    Join Date
    07-21-2014
    Location
    Atlanta, GA
    MS-Off Ver
    MS Excel 365
    Posts
    19

    Re: Can I show the difference between 2 counted columns in a pivot?

    This thread just helped me tremendously! Thank you

+ 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: 3
    Last Post: 07-11-2018, 05:33 AM
  2. Compare two columns and show only the difference in the third column
    By DanzaNZ in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 12-13-2017, 03:07 AM
  3. Difference between two counted columns in Pivot
    By specialk9203 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 04-09-2015, 01:15 PM
  4. Comparison between 2 columns of data and show the difference
    By craye in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-10-2014, 05:00 AM
  5. Pivot Table to Show difference between Min and Max Value
    By bigroo1958 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-20-2013, 09:06 PM
  6. Replies: 7
    Last Post: 08-04-2011, 09:32 AM
  7. Replies: 7
    Last Post: 01-30-2005, 02:06 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