+ Reply to Thread
Results 1 to 11 of 11

Pivot Table - Adding a calculated field for gemean of all visible data columns

  1. #1
    Registered User
    Join Date
    11-25-2022
    Location
    Texas
    MS-Off Ver
    365
    Posts
    5

    Question Pivot Table - Adding a calculated field for gemean of all visible data columns

    Hi, I have tried hard to answer my own question, but I have not been successful. I have a large table from which I have created a Pivot Table in Excel (office365). I have set up several filters to narrow what I want to see. The "columns" field in the "Pivot Table Fields" area has one "Region" field which in the data table covers many regions. Once the filters are applied only a few become visible in the pivot table (for example, only Regions 1, 5, 7, 10, 43 are shown). The "rows" field in the "Pivot Table Fields" area has one "Product" field which contains many products in the data table. Once the filters are applied, only a few become visible in the pivot table (for example, Product A, B and C). The "values" field in the "Pivot Table Fields" area has one "Max of Price" field. The resulting pivot table has three Product rows and five Region columns with max product prices for each column and row.

    I have added a calculated item as a new row that computes the price difference between two products for each region.

    I want to add a calculated field that computes a geomean of all regional product prices for a given product (in essence, compute a geomean for each row). I am not able to add this geomean column that operates across all visible columns for each row. If the filters are changed, the number of regions and products displayed could expand or shrink. The calculated field should operate correctly regardless of the size of the displayed table.

    I'd appreciate any help you can provide.

    Thank you.
    Attached Files Attached Files
    Last edited by neskowin; 11-25-2022 at 07:23 PM. Reason: Added a sample excel file

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    ................................
    attach.png

  3. #3
    Registered User
    Join Date
    11-25-2022
    Location
    Texas
    MS-Off Ver
    365
    Posts
    5

    Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    Thank you. I have added an example spreadsheet. Please note that my real application is different. To protect the data confidentiality, I created the example file using equivalent column names and dummy data.

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    you green table is from Power query
    the structure and type of data are the same as in the original?
    and where is your calculated field???
    ok, it's calculated Item NOT field
    Last edited by sandy666; 11-25-2022 at 08:12 PM.

  5. #5
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    you can try when you create Pivot Table use Add to Data Model and next use DAX measure: GEOMEAN(<column>) or GEOMEANX(<table>, <expression>)

    maybe it will help
    Attached Files Attached Files
    Last edited by sandy666; 11-26-2022 at 12:00 AM.

  6. #6
    Registered User
    Join Date
    11-25-2022
    Location
    Texas
    MS-Off Ver
    365
    Posts
    5

    Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    I have attempted to use DAX. The geomean formula works on columns only. For me, the column field has multiple columns. I am looking for a way to compute the geomean across all the visible columns, row-wise.

  7. #7
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    you can try
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    or
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-25-2022
    Location
    Texas
    MS-Off Ver
    365
    Posts
    5

    Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    Thanks. I tried the following: Geomean := CALCULATE ( GEOMEAN ( Table1[Price] ), ALLSELECTED ( Table1[Region] )) This computes the geomean correctly. However, I am able to add this measure only to the "Values" field which then results in the geomean replicated for each column in the visible table. Is there a way to show it only as the last column? Thank you.

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    You can try to AddColumn with the same DAX formula (not Measure)

  10. #10
    Registered User
    Join Date
    11-25-2022
    Location
    Texas
    MS-Off Ver
    365
    Posts
    5

    Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    Thank you. I will try it. I also noticed that my table has to be in a data model for DAX to work. With DAX, I am no longer able to add a row of calculated item (my price difference example). Is this possible with DAX? Thank you.

  11. #11
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Pivot Table - Adding a calculated field for gemean of all visible data columns

    you can try with DAX your "calculated item" (Measure) but, sorry, this is not my melody
    good luck

+ 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: 1
    Last Post: 09-25-2022, 09:06 AM
  2. Replies: 1
    Last Post: 01-15-2019, 08:54 PM
  3. adding calculated PowerPivot field to Pivot Table
    By AtlanteanIdol in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-09-2017, 09:49 AM
  4. Replies: 0
    Last Post: 02-18-2013, 03:50 PM
  5. Adding new calculated/column field to pivot table
    By MARYAN in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-09-2010, 05:34 AM
  6. Pivot Table - Adding Average as calculated field
    By Matt1234au in forum Excel General
    Replies: 4
    Last Post: 12-22-2009, 08:50 PM
  7. Replies: 3
    Last Post: 02-23-2009, 10:07 AM

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