Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TIme Math Excel 2007 PivotTable Calculated FIeld

Posted on 2012-03-09
3
Medium Priority
?
371 Views
Last Modified: 2012-08-14
Greetings Experts:

I have an Access 2007 data source that has information about trucks arriving and departing. The time stamps are text fields in military time, like this:

Arrive     Departure
08:34     11:15
17:59     18:28

I tried to create a calculated field in Excel pivottable to give the elapsed time in minutes, but I am unsuccessful. Every attempt either shows 0, 12:00:00 AM, 00:00 or #VALUE. I tried

=Departure-Arrive
=24*(Departure-Arrive)
=left(Departure,2)*60+right(Departure,2))-(left(Arrive,2)*60+right(Arrive,2)
=TIMEVALUE(Departure&":00 PM")-TIMEVALUE(Arrival&":00 PM")


plus several other variations along those lines.

When I create a formula to do the time math in a cell outside the pivot table, it kind of works.

=24*(N13-M13)

If N13 is "14:14" and M13 is "10:26" I get 3.8 hours.

I DID get the elapsed time into the pivottable by including this in the SQL Command Text in the Definition of the Connection properties:

SELECT ....(fields I want)....

....abs((left(Departure,2)*60+right(Departure,2))-(left(Arrive,2)*60+right(Arrive,2))) AS 'Elapsed'....

.... FROM (Access data file)....


The same formula in the Calculated Field dialog of the pivottable didn't work.

So the question is:

How do I get the calculated field in the pivottable to work and not have to resort to using the substring extraction functions in the SQL?

Thanks!
0
Comment
Question by:jkasavan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 37708771
Can you not just use:

Arrival_time: TimeValue([Arrive])

in your query, and similarly for the Departure?
0
 
LVL 2

Author Comment

by:jkasavan
ID: 37710780
Yes, TimeValue([Departure])-TimeValue([Arrive]) works in the query. I am able to get the elapsed time by creating the calculation in the query.

But, what I am trying to find out is if there is a way to create the elapsed time as a calculated field in the pivot table.
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 37710796
I don't believe so since any operations you do on a calculated field occur after the field values have been aggregated. Since your 'values' are actually text, the aggregation returns 0 and anything you try and do after that is too late. You either need to alter the query, or use an additional formula column in the data.

Regards,
Rory
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

721 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