Solved

Pivot Tables - Calculated Value

Posted on 2011-02-22
15
622 Views
Last Modified: 2013-11-05
I have a Pivot table that has a variable (set to Count) that has columns over a 10 year period.  The last year/period represents only a potion of the year so I would like to "annualize" the last year/period data.  I want to do this by dividing the last years count value by the ratio of days currently represented in the year to date (e.g., .141 for date in February).  I've looked at calculated variables but it does not appear that you can work with a count value and modify it as I've described.  I reuse the same pivot table for different data sets that (using VBA) that prohibits me from putting the pivot table value in a normal Excel cell and doing the calculations.  I pull the values directly from the pivot table to a data select on an Excel chart.  
0
Comment
Question by:jaustinr
  • 9
  • 6
15 Comments
 
LVL 41

Expert Comment

by:dlmille
ID: 34957613
Can you upload a non-confidential sample of data?

Dave
0
 

Author Comment

by:jaustinr
ID: 34957807
I will look at how I might display the PT.  The underlying data is really not an issue and should have no impact on the solution.  I simply have a variable in the PT that I've set to Count.  The PT summarizes the number of rows associated with that variable as a number (count).  I have a count for each of the 10 years of data I'm analyzing.  Since I don't have a full year for 2011 I want to correct the 2011 count by dividing by a correction factor.  As I noted, I cannot pull the 2011 count to a cell and do the calculations as the overall automated analysis procedure requires I pull the data directly to an Excel chart process.  The exact PT path for each chart value is inserted into the "select data" function of the Excel chart.  I need to find a way to correct one of the values before plotting.  I've tried to add calculations into the select data area but it isn't compatible with this type function.  I've also looked at using a calculated value but don't see a way to use a count (of a variable) in the calculation.

jaustinr
0
 
LVL 41

Expert Comment

by:dlmille
ID: 34958125
I understand, but it would be a simple think for you to create a simple problem I can help you to solve, as opposed to me straining my brain to simulate that.  I'm willing to help you solve the problem - are you willing to create a sample dataset so I can help you solve the problem?

Dave
0
 
LVL 41

Assisted Solution

by:dlmille
dlmille earned 250 total points
ID: 34958293
Ok - I took a bit of time and thought about the problem.  Then, I created my own sample dataset - so I hope this suits.  Sometimes by creating a sample (data does NOT matter, that's correct - but pictures in the mind saves thousands of words - or the 339 you used to describe the problem :)

Anyway, I hope this works for you.  I created a simple dataset with two people, and salaries over a 5 year period (how much was earned between two dates - start of year to end of year.  In the final year, the ending date was earlier than December 31.

I then created a couple columns in the data (for check purposes only, as I realize you cannot create these in your dataset!)  One for the fraction of the year, then dividing by the salary earned achieved the ANNUALIZED salary.

Ok, once satisfied I had something to solve for, I created the pivot table.  Then, I created 2 calculated fields (I assume you are familiar with these as your question uses this language, so I'll forgo what buttons to press to get there).

YearFraction = (end - start +1)/365 - not counting leap year as this is an example
AnnualizedSalary = Salary / YearFraction


Then, I put these in the pivot table and checked against the table I created in the spreadsheet and (presto) they were the same.

Here's hoping this is your solution :)

Please see attached demo example.  Please feel free to ask questions, if needed.


Enjoy!

Dave
PivotTableProration-r1.xlsx
0
 
LVL 41

Expert Comment

by:dlmille
ID: 34958299
If this is the not direction you're going, or you want something more precisely like what you're trying to do, then please provide SAMPLE DATA to help with clarification.

Thanks for your indulgence as it will help speed responses and solutions!

dave
0
 
LVL 41

Expert Comment

by:dlmille
ID: 34958313
If the solution doesn't suffice and you need help generating sample data or example - you could provide a print screen of your pivot table or even double click one of the value fields to generate a simple 1-row table that could be useful in assisting you further.

Cheers,

Dave
0
 

Author Comment

by:jaustinr
ID: 34960157
Dave,
I guess I should have used all 500 words (or a lot less) to describe my problem. :)  I really appreciate your taking the time to look at my issue.  You are exactly on the path of what I'm trying to do.  In your example, I have the year fraction.  Since I do an update 1-2x/month, so this is not an issue.  However, my "salary" variable is actually a "count" of salaries.  So, my real problem is how to do additional calculations (within PT) on the count.  At this point, my only solution may be to create the annualized data point back in Access where my original dataset resides.  However, not sure how that would interact with my PT and it makes the process a lot more complex.
Thanks again and any additional thoughts appreciated.

John
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 41

Expert Comment

by:dlmille
ID: 34973413
Just give me a few rows of made-up data, or a made-up snapshot of your pivot, and I can help, further.
0
 
LVL 41

Expert Comment

by:dlmille
ID: 34993718
Ok - willing to try this once more, without data - which would be really refreshing.  Many times we can give you exactly what you asked for, and yet that's not what you're LOOKING for.  A PICTURE is worth 1000 words and sometimes 1000 words don't get it :)

Here it goes.  I assume there's two people, with fraction thru the year called Annualized Fraction (which you say you have) and have received # of paychecks (no ryme or reason, that's just how many times they got paid).

So the # paychecks is your COUNT of salaries, for example purposes.

Then...

Annualized # paychecks (annualized count) = # Paychecks / Annualized Fraction.

If I'm off here, I'd like you to at least show an example to me just like how I'm explaining to you.

So if Mary has had 12 paychecks and her annualizing fraction = .5, the Annualized # Paychecks would be 24.

Here's the example, see attached range 36-48 of the data and pivot table.  I clicked in the data, then selected Pivot Table tools, then Formulas, and added a Calculated Field, called Annualized Count, with the formula above, see picture.
ExampleAlso, see attached.

Enjoy!

Dave
PivotTableProration-r2.xlsx
0
 

Author Comment

by:jaustinr
ID: 34994449
Dave,

Your most recent approach looks very promising.  I have to be out of town for a couple of days, but will definately try it when I return

Thanks for continuing to pursue

John
0
 
LVL 41

Expert Comment

by:dlmille
ID: 35065773
How's it going?  Is this working for you?

dave
0
 

Author Comment

by:jaustinr
ID: 35068328
Dave,

Just returned from travel and had a couple of things get in the way.  Plan on trying today or tomorrow.  Will let you know my results.

Thanks,

John
0
 

Accepted Solution

by:
jaustinr earned 0 total points
ID: 35218812
Dave,

Sorry for the delay.  The problem with your solution is that you have a count variable in your original dataset.  My count comes from using a variable in the data and using the Value Field Settings window to set the type calculation to Count (instead of sum, max min, etc.).  So when I use your approach to go to Tools/Formulas/Calculated Field, the only variable that show are the original variables, not the count of a variable (or any of the other standard variable calculations). I've played around using a "count(variable name)/annualize factor" in the formula field (for calculated value). This seemed to give me a proper value, but it creates additional problems. I have grouped years and it appears that the calculated value makes some changes in the PT cache.

Thanks for thinking about this and providing recommendations.  

John
0
 
LVL 41

Expert Comment

by:dlmille
ID: 35219902
I am willing to pursue this only if you provide sample dataset representing what you're working with.  

Cheers,

Dave
0
 

Author Closing Comment

by:jaustinr
ID: 35304183
Solution was found by expert guiding me through the logic process and I was able to find a direct solution.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now