+ Reply to Thread
Results 1 to 8 of 8

Pivot Table Measure based on Column Values

  1. #1
    Registered User
    Join Date
    04-16-2020
    Location
    England
    MS-Off Ver
    Office 386
    Posts
    14

    Pivot Table Measure based on Column Values

    Hello,

    I am sure this is going to be a lot easier than I am making it out to be, but I just cannot figure out how to do what I would like.

    I have the following Pivot Table (added to data model)

    PivotTable.jpg

    I would like to add a measure which replicates the percentage shown to the right of the pivot table but cannot figure out how to do it.

    The add Calculated Field option is grey out as the source has been added to the Data Model, I just do not know how to reference the column values for each vehicle when creating a Measure. (if a measure is the "thing" I need to be creating)

    Any and all help is greatly appreciated


    [EDIT] I have now added an example file to the post.

    [Update] Issue, solved by item #6 in the list.

    Regards
    Mike
    Attached Files Attached Files
    Last edited by MLAN_75; 03-26-2021 at 11:42 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Pivot Table Measure based on Column Values

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    04-16-2020
    Location
    England
    MS-Off Ver
    Office 386
    Posts
    14

    Re: Pivot Table Measure based on Column Values

    Thanks @alansidma

    I have updated my post to include an example now.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Pivot Table Measure based on Column Values

    See the attached. Right click on the row value for personal and select % of Row

    Excel 2016 (Windows) 32 bit
    H
    I
    J
    K
    L
    1
    Classification
    2
    Business Personal
    3
    Vehicle Sum of Distance Distance (Miles) Sum of Distance Distance (Miles)
    4
    ABC123
    305
    70.44%
    128
    29.56%
    5
    DEF456
    200
    51.41%
    189
    48.59%
    6
    GHI789
    224
    54.37%
    188
    45.63%
    7
    Grand Total
    729
    59.08%
    505
    40.92%
    Sheet: Example
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-16-2020
    Location
    England
    MS-Off Ver
    Office 386
    Posts
    14

    Re: Pivot Table Measure based on Column Values

    Hi @alansidman,

    Thanks for the response, however, it is not really what I wanted. I realise that it is giving me what I have asked for in terms of a Percentage of the Row total, but doing it that way also drops in the Percentage for the Business Mileage and I do not want to display that value, I know I can Hide the Business Distance (Miles) column if I want but that is not always possible.

    I really wanted another thing which I could drag onto the pivot which just calculated the percentage of the Personal Mileage, similar to the screenshot of my manual method.

    PivotTable 2.jpg

    If there is no way of doing this then that is fine, but I was hoping for a way of adding a new Measure that worked out the value from the related data, this would be useful for other custom columns using data already in the pivot.

    Something like this in DAX code

    = IF([Classification]="private",SUM([Distance]))/SUM([Distance])

    I know this doesn't work but this was the hope and idea.

    Thanks for taking the time to have a look and reply.

    Regards
    Mike

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

    Re: Pivot Table Measure based on Column Values

    Try the following measures:
    Business:=CALCULATE(SUM(T_Data[Distance]),T_Data[Classification]="Business")
    Personal:=CALCULATE(SUM(T_Data[Distance]),T_Data[Classification]="Personal")
    Personal %:=[Personal]/([Business]+[Personal])
    Note that you may format Personal % as percentage with no decimal places in the data model window.
    In the pivot table put Vehicle in the Rows area and then Business, Personal and Personal % in the Values area (Classification and Distance are not used).
    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.

  7. #7
    Registered User
    Join Date
    04-16-2020
    Location
    England
    MS-Off Ver
    Office 386
    Posts
    14

    Re: Pivot Table Measure based on Column Values

    Thanks, @JeteMc, spot-on reply, the perfect solution and generic enough that I can use this technique in other situations.

    It has re-introduced me to the CALCULATE function.

    Right, now how do I mark the question as Solved?

    Many Thanks
    Mike
    Last edited by MLAN_75; 03-26-2021 at 11:41 AM.

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

    Re: Pivot Table Measure based on Column Values

    You're Welcome. Thank You for the feedback and for marking the thread as 'Solved'. I hope that you have a blessed day.

+ 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. Duplicating Values in Power Pivot Table (DAX Measure?)
    By jmklei0 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-07-2021, 11:14 AM
  2. Replies: 4
    Last Post: 07-01-2020, 02:13 AM
  3. Pivot Table: Grand Total different measure from Column measure
    By chinneywow in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 08-07-2019, 06:22 AM
  4. pivot table with DAX measure
    By mlaxx in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-12-2019, 02:24 PM
  5. Pivot Table Calculation (Measure) Formula Help
    By sovietchild in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-21-2018, 10:31 AM
  6. Format a pivot table based on values of a pivot column
    By chytechplus in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-25-2016, 06:32 AM
  7. Replies: 1
    Last Post: 11-29-2011, 10:52 PM

Tags for this Thread

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