• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

How to add calculations to a pivot table?|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / How to add calculations to a pivot table?|General Excel Questions & Answers|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumGeneral Excel Questions & Answe…How to add calculations to a pivot …
sp_PrintTopic sp_TopicIcon
How to add calculations to a pivot table?
Avatar
lea cohen
Member
Members
Level 0
Forum Posts: 219
Member Since:
March 10, 2016
sp_UserOfflineSmall Offline
1
March 27, 2022 - 11:36 am
sp_Permalink sp_Print sp_EditHistory

In the attachment in the issue - Sheet1

I relied on the file I downloaded in your amazing webinar

I built a pivot report
And I need calculations based on the total amount
I added the calculations manually - but when I add the category to the rows of the report - it deletes the manual calculations.
How do I add calculations to the overall summary that will be part of the pivot report?

sp_AnswersTopicSeeAnswer See Answer
Avatar
lea cohen
Member
Members
Level 0
Forum Posts: 219
Member Since:
March 10, 2016
sp_UserOfflineSmall Offline
2
March 27, 2022 - 11:40 am
sp_Permalink sp_Print sp_EditHistory
Unable to upload file
Then I will attach a picture33.jpgImage Enlarger
sp_PlupAttachments Attachments
  • sp_PlupImage 33.jpg (82 KB)
  • sp_PlupImage 33.jpg (82 KB)
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4449
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
3
March 28, 2022 - 9:51 pm
sp_Permalink sp_Print

Hi Lea,

If it's a regular PivotTable then the only way to add columns that are retained by the PivotTable is to add it as a Calculated Field or Calculated Item. If it's a Power Pivot/Data Model PivotTable then you need to write a DAX measure.

Mynda

Avatar
lea cohen
Member
Members
Level 0
Forum Posts: 219
Member Since:
March 10, 2016
sp_UserOfflineSmall Offline
4
March 29, 2022 - 12:10 am
sp_Permalink sp_Print sp_EditHistory
I started working on DAX in Power Pivot
My problem now is that I need the percentages only for the final total and not for all the lines (As in the attachment 11)
- how can this be defined ??
I need the result to be similar to the example attached here in the image (As in the attachment 33)
33-1.jpgImage Enlarger
11.jpgImage Enlarger
Thank You!!!!!!!!!!!!
 
sp_PlupAttachments Attachments
  • sp_PlupImage 33-1.jpg (82 KB)
  • sp_PlupImage 11.jpg (69 KB)
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4449
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
5
March 29, 2022 - 12:15 pm
sp_Permalink sp_Print

Hi Lea,

PivotTables don't work like that. They don't leave cells blank, they're designed to aggregate the data based on the row and column labels. You might be better off using CUBE functions if you're using the data model, or GETPIVOTDATA.

Mynda

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 627
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
6
March 29, 2022 - 6:58 pm
sp_Permalink sp_Print

If I understand you correctly, you could achieve that look with a row set by only showing the field for the totals row.

Avatar
lea cohen
Member
Members
Level 0
Forum Posts: 219
Member Since:
March 10, 2016
sp_UserOfflineSmall Offline
7
March 30, 2022 - 2:44 am
sp_Permalink sp_Print
The GetPivotData
Allows me a formula outside of the pivot and if I make changes to the pivot structure it disappears.
The CUBE function looks amazing but I prefer to be based on the pivot rather than create a re-report.
The question is how can you add a calculated field / item to the total amount 
- which will be part of the report and its location will change even when the structure of the report changes ??
Below the line Total amount - a calculation result of amount * 0.17 will be obtained
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4449
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
8
March 30, 2022 - 10:42 am
sp_Permalink sp_Print

"The GetPivotData allows me a formula outside of the pivot and if I make changes to the pivot structure it disappears." Build a separate PivotTable to support your requirements and link GETPIVOTDATA to that PivotTable so the values are always available.

Alternatively, take Velouria's suggestion and don't drill down to the lower row label level, so you only see the totals.

Mynda

Avatar
lea cohen
Member
Members
Level 0
Forum Posts: 219
Member Since:
March 10, 2016
sp_UserOfflineSmall Offline
9
March 30, 2022 - 1:17 pm
sp_Permalink sp_Print sp_EditHistory

Thanks for the response,
It is still not clear to me how to use with GetPivotData
Attached is a sample file
Where the years and months are in the columns
When you look at all the months - the formula works great
But when I only show the years - a REF error is obtained
And if I want to add another element to the lines of the report - everything goes wrong.

And there are 2 sections in the lines - if you only show the main section then the formula is not attached to the report
 and there are many lines in the middle

what can we do??

Please refer only to this file - GetPivotData-Question-1.xlsx
I could not remove the other files

I would appreciate an answer on the attachment so I will better understand the solution.
Thank you very much for answering and being patient with all my questions !!
Leah

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4449
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
10
March 30, 2022 - 7:50 pm
sp_Permalink sp_Print

Hi Lea,

See file attached. Note: if you add fields to the rows area in the PivotTable with the calculated field you will get the 17% applied to every row. There is no way around this. This is how PivotTables are designed to work.

Mynda

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 627
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
11
March 30, 2022 - 9:05 pm
sp_Permalink sp_Print

This is an example of using a row set. I had to amend the MDX manually to make sure it will adjust if new products are added (which was not easy for me with a right-to-left setup!)

sp_AnswersTopicAnswer
Answers Post
Avatar
lea cohen
Member
Members
Level 0
Forum Posts: 219
Member Since:
March 10, 2016
sp_UserOfflineSmall Offline
12
April 1, 2022 - 5:45 pm
sp_Permalink sp_Print

Velouria, your solution with the SET looks great
The thing is, I need more lines of calculations
I would like a brief instruction - how do I set up a set and enter the required calculations?
Thanks so much for the help and patience !! Leah

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 627
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
13
April 1, 2022 - 6:27 pm
sp_Permalink sp_Print

Add the fields you want calculated to the pivot table, then on the Pivot Table Tools, Analyze tab, use the 'Create set based on row items' option. That will allow you to remove any rows where you don't want the calculations shown (basically all the detail level).

Avatar
lea cohen
Member
Members
Level 0
Forum Posts: 219
Member Since:
March 10, 2016
sp_UserOfflineSmall Offline
14
April 1, 2022 - 6:41 pm
sp_Permalink sp_Print sp_EditHistory
Is there a guide on how to work with set based?
And how do you work with MDX? Where did you add the calculations ??
 
 
 
Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 627
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
15
April 2, 2022 - 10:08 pm
sp_Permalink sp_Print

You add the calculations as measures in the data model, not using MDX. The MDX only determines what level of detail is shown in the set but you can do most of it manually in the UI by adding and deleting rows as needed.

 

I’ve never seen a guide to working with sets but I’m sure there must be one.

Avatar
lea cohen
Member
Members
Level 0
Forum Posts: 219
Member Since:
March 10, 2016
sp_UserOfflineSmall Offline
16
April 5, 2022 - 10:31 pm
sp_Permalink sp_Print
Hi,
I have now tried to work with estimates, the problem is that there are no wide shrink buttons
And my report consists of many lines.
Is there a way to set that I can shrink in the report - and not within the scheme management?

I was thinking of performing this process with a macro?
That every time I want the calculations - I will define the report that will look like I want now - my question
 - how in a macro recording define that it will come to the last line of the total ???
sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: RAMEZ ATTAR, SALLY
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Bhuwan Devkota
Forum Stats:
Groups: 3
Forums: 24
Topics: 6222
Posts: 27293

 

Member Stats:
Guest Posters: 49
Members: 31918
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.