Excel - A row in my Pivot table calculates sum wrongly only for some entries (same data type/format) - excel

I created a tracker of learning hours in order to conduct an experiment.
For the purpose of the ticket, there is a time series that does not sum correctly data in Pivot table.
Some other tickets on Stack Overflow mention how to correctly sum. Here's what I tried:
considered blank spaces > the Pivot does not consider them anymore, yet the issue persist.
data type & format > the whole column is set for data type short date
labeling > I use to copy-paste the category for each learning and I double checked if there was no typo in them.
Here's how the file works. There are 3 sheet in my Excel file. The core of it is "Data" where I do track the time spent for each learning / exercise. The columns marked in red are the ones used for the next Pivot Table.
These information are consolidated in another sheet, called SuperLearner Review. I use this one to display overall learning hours by type and category. Numeric outputs here are looked up from Data (or calculated accordingly).
After several checks, I cannot retrieve the issue. All I know is that for February data are not tracked correctly.
Originally I attributed either to wrong data labeling or format, but I can manually see what is the real sum of learning done in February:
In the data-series those hours seem not to display. This is what the Pivot table returns instead:
Whereas, for the consolidated information (coming from the same source) does not seem there are problems in calculation:
When I tried to cancel and build up again the same Pivot Table, the same error occur. So I am not getting out of this wrong calculation. Therefore it must not be a problem of calculation, rather than Excel does not retrieve some data entries at one point.
What would you recommend? Thanks for the help.

Related

(excel) Calculated Field not available for a power pivot table

I'm trying to create a column in a pivot table I've created that calculates the difference between a forecast and actual cost column. Under 'Fields, Items, & Sets', 'calculated field' is grayed out/unavailable. From other forum posts as far back as 2010 (all with dead links to websites meant to explain it more), I've heard that this has something to do with using data that comes from an OLAP table.
My 'actual cost' data is being pulled from a server and funneled into a group of tables on separate sheets. I also have a manual entry sheet for the forecasts (also type table) that's being connected to it. that I'm The cell count is in the millions and steadily increasing, so it's understandable that the system uses OLAP to refresh manually (it takes about a minute to 'refresh all'). That said, I don't know why this would prevent me from doing math with these columns. I've looked up some videos on OLAP and I figure it's just above my head. I've looked into converting it into a "dynamic range" per a recommendation from about 10 years ago, but there isn't much about what that actually is online and I'm not sure I'd be able to do that with how I'm pulling it from the database. That, and I'm doing about 2 weeks worth of operations that are probably dependent on it being a table. I'm not even sure if you can feed data into power pivot if it's not a table.
I have a way that I think I can do this, but it requires about a week's worth of work manually building out a massive, un-iterative sheet. It would pull all of the values for a specific job of each activity type, sum them, and then compile them into another table that can be used to find the difference between the values of forecast and actual. But, at that point I'm basically just making a worse pivot table infrastructure from scratch.
Is there a way that I can just side-step this issue? I've only been using power pivot for a few weeks and this is the first time I've had to do math between columns, so it may be that I'm missing something that most people know.

Excel Pivot Table difference in columns of "shown as" values

Is there a way to let a pivot table calculate the difference between 2 columns automatically when the values are shown as a % of the parent column total?
Now I need to to manually but the table is dynamic and number of competitors may vary. Function seems so easy but can't find it after googling etc...
See example picture below of what I want to achieve.
(Column F automated by the pivot table is the goal)
If trying to solve this with PivotTables, you've got a couple of options:
Use a 'Traditional' PivotTable that's based on a range. This will give you percentage differences, but you can't get percentage point differences like you're asking for without using external formulas.
Use a 'OLAP' PivotTable that's based on data you've added to the Excel Data Model. This will give you both percentage differences and percentage point differences, without having to resort to using external formulas.
In both cases, I recommend that you unpivot your data first, so that it is in what's known as a Flat File. Currently you're using a cross-tabulated data source (i.e. your source has columns called Year 1, Year 2), and the type of percentage comparisons across years you want to do doesn't work if your data is a crosstab. Basically, PivotTables aren't meant to consume cross-tabulated data.
Instead, you really want your data laid out so that you have a column called Amount and a column called Year, and then you can use the Show Values As options available from the right-click menu to show as percentage differences across years. To transform your data into a flat file, see my answers at convert cross table to list to make pivot table
That said, you can still use the GETPIVOTDATA function on your existing (unpivoted) data layout in a way that is somewhat more robust to changes in your PivotTable structure than just subtracting one reference from the other:
But again, I recommend transforming your data into a Flat File. Then you can additionally do the following:
Using a 'Traditional' PivotTable:
You can kinda solve your problem entirely within a self contained 'Traditional' PivotTable if you drag the Amount column to the Values area, put the Year column in the Columns area, put your Competitors in the Rows area, and choose one of the percentage Show Values As options you'll see when you right-click a cell in the Values area.
I say kinda, because without using external formulas (or without calculating the percentages back in your source data), you can only get it to show percent increases (see far right column), not percentage point increase like you want (see far left column). That said, I think percent increase is less confusing. But I guess it depends on what you want to show. If you want to show say change in market share from one year to the next, then percentage points make sense.
Of course, you could always use the GETPIVOTDATA function to do the additional math for you like we did earlier, like I've done on that left hand side.
Using an OLAP PivotTable based on the DataModel
Calculating percentage point increases likely requires using PivotTables built using the Data Model. See my answer at https://stackoverflow.com/a/49973465/2507160 that explains a little about the Data Model (although it doesn't answer this specific question).
Here's the result:
Here's the measures I used to do this:
Total Year 1:
=CALCULATE(SUM(Table2[Value]),ALLSELECTED(Table2[Competitor]),Table2[Year] = "Year 1")
Total Year 2:
=CALCULATE(SUM(Table2[Value]),ALLSELECTED(Table2[Competitor]),Table2[Year] = "Year 2")
% Year 1:
=CALCULATE(SUM(Table2[Value]),Table2[Year] = "Year 1")/[Total Year 1]
% Year 2:
=CALCULATE(SUM(Table2[Value]),Table2[Year] = "Year 2")/[Total Year 2]
p.p. Diff:
= [% Year 2] -[% Year 1]
You can add Calculated Fields to Pivot Tables, of varying levels of complexity. Finding the difference between two fields is about as simple as it gets.
The example below is borrowed from contextures.com, where there are many more examples more further information.
To add a calculated field:
Select a cell in the pivot table, and on the Excel Ribbon, under the PivotTable Tools tab, click the Options tab (Analyze tab in
Excel 2013).
In the Calculations group, click Fields, Items, & Sets, and then click Calculated Field.
Type a name for the calculated field, for example, RepBonus.
In the Formula box, type =Total * 3%
Click Add to save the calculated field, and click Close.
The RepBonus field appears in the Values area of the pivot table, and in the field list in the PivotTable Field List.
(Source)
EDIT:
#jeffreyweir - I'm not gonna lie, I don't know off the top of my head how to make this work (and don't have time to experiment) but by the looks of these options, isn't a calculated field with a "straight subtraction" of existing fields (ie., 3$-2%=1%) very possible with Difference from? (as opposed to % Difference from which is also an option but for a different result).
In fact, automatic year-over-year difference reporting should be readily possible with the <previous> and <next> comparison operators...?
                                 (Click to Embiggen)
     
Also, did you see the link where I got the example? Kind of a hoakey site but it has some more complex pivot table instructions.

Excel vba to work out average score

the attached shows a small example of a scorecard i have at work for drivers, the list is many lines long, around 120 drivers, i export a report each week and it produces the attached, i have added code to tidy it up and work out scores. I then have to work out an average score for the week for each driver but can't for the life of me think how to do it using code. Any help would be appreciated.
Fill the empty cells with the respective driver names and then build a pivot table. No code required to calculate averages per driver per week. That's just a few clicks. Add more data and refresh the pivot table. No VBA. Just Excel out of the box.
You may not even have to produce the report in the screenshot, but start with the original data. Pivot tables are used for exactly that: aggregate, slice and dice large amounts of data.

Sorting error for Time row value in Pivot Table

I've encountered an issue with a pivot table that I occasionally use, though I don't update. Specifically there are three Row Fields applied Year, Day (d-mon format), and then Transaction Date/Time (which displays only the hour component of the value). The pivot table is supposed to sort by Year, then Day, then Hour. The first two sorts work fine, but the third has started to sort the Hour values as text rather than numbers, so it's ordered 1 AM, 1 PM, 10 AM, 10 PM, etc. I've checked and there are no non-time values in the source field, the column of the pivot table itself is still set to a Time format type, and there are no filters applied to the field.
At this point I'm not sure what else to look for. Any assistance would be much appreciated.
UPDATE: The file is in Sharepoint so I tried taking the prior version (there are only two), dropping in the latest data from the current version, and refreshing the pivot table. The error dutifully appeared. So it does appear to be a data issue, but I can't imagine what's causing the issue. As stated above, I already checked that the values were Dates, specifically I used =IF(NOT(ISERROR(DATEVALUE(TEXT(C2, "m/d/yyyy h:mm"))), "", 1) and checked that all rows returned as blanks.
Something that may be causing issues is how the Year and Day fields come about. Specifically, there are no such fields in the Source Data, they are calculated Row Fields based on the one Transaction Date/Time column. I'm not even sure how this was done (to my knowledge calculated fields can only be columns) so I can't really look into if it may be causing the errors.
I also had this problem and found no good way around it in Excel. What I ended up doing (that worked for me) is to extract the 24hour "hour value" from a date field using =VALUE(TEXT(A2,"h")) (where A2 contains the time/date code I'm looking for). I then used the date code itself (Column A in this example) as the first Row Label (first grouped item) then added the "hour value" as a secondary Row Label/Group. This allows leveraging the Pivot Table sort/group function naturally and then adds the detail in the order I want.
I did not solve the problem for 12 hour display with AM/PM as this was good enough for my needs.

Dynamic Excel 2007 Dashboard Without VBA

Morning guys,
I'm hoping that one (or more) of you can help me.
I have been tasked with creating a dashboard which needs to display trends and have a dynamic frontsheet, preferably with drop-down or data forms so as to update a chart / graph.
The information itself is incredibly limited - the scope of the document is tracking a value (0-4) assigned to a staff member's ability to fulfill a task, e.g. 'Quotes - 4', 'Cancellation - 2' and so on. So the metrics are limited to:
Month (a worksheet for each month of the year and one front for the dashboard)
Team (Presently 6 teams, but this is likely to increase over time, so hopefully the solution facilitates relatively easy incorporation of new teams)
Employee (Self explanatory)
Task (Presently 25, but as above - subject to change)
Score (the 0-4 value referred to above)
So as you can see, it's a very simple dataset. The sheets are presently set out with six grids with data validation lists for determining Team and Score (dropdowns for easy data input), with the Task being pre-written and the employee entered manually by the user.
What I'm hoping to do is have a frontsheet with dynamic tables that update accordingly when a dropdown and/or data form is changed. The key focus is on getting the staff members up to 4s for all tasks, so ultimately, the charts will display trends for the individual teams (one chart for each team - 6 charts) on a month-on-month basis and also a dynamic table which can reflect specific information (e.g. employee performance on a specific month, or number of '3s' achieved by a specific team to date).
I've read a reasonable amount on this, but seem to have overwhelmed myself with the sheer amount of options. However, the options can be narrowed given that I'm working on a large corporate network that doesn't really facilitate downloads (so add-ins or anything extraneous to Excel 2007 'out-the-box' isn't an option) and preferably without the use of VBA (1. I'm quite a novice insofar as VBA, 2. Easy distribution and maintainence of the document might be marred by VBA?), though I appreciate that my requirements may dictate VBA to be essential.
Does anyone have any suggestions around how best to proceed creation of this dashboard?
Any and all help is appreciated and I apologise as a newbie if I've contravened any conventions around forum etiquette.
Thank you all for your time,
Rob
There are a couple of things that you need to consider in a task such as this:
a) what sort of output do you require?
b) how are you going to manage the data?
For a) I'd separate it further into the basics of what's required (time series charts of employee and/or team performances [how will team performance be measured? average, % achieving 4, or ?]) and then the bells and whistles of drop-downs. Focus on the basics, the other stuff first the whizzy stuff can come later. Getting b) right is vital - you are going to be extracting subsets of the data to build the charts you want to display. Get b) wrong and you'll just create a horrible task for yourself.
In your position I would consider re-organising the data into the form of a table. Excel's help defines what is meant by a table, but in essence it is a list of your observations where each observation simply comprises the score for a particular month/team/employee/task combination (so each observation comprises 5 values). The observations are arranged as successive rows of the table with the first row being the header row which will contain suitable labels such as "Month", "Team", "Employee", "Task", "Score". The real advantage of using a table such as this is that Excel provides a heap of in-built facilities for manipulating them - look up the help for Sort and Filter on the Data tab. In your case there is an even more compelling reason for using a table - you can use the Pivot Table and Pivot Chart facilities for analysing and displaying the data. If you have not used these before some time and effort spent learning about them will pay dividends. Once your data is organised and you know how to use Pivot Tables and Charts you should be able to prototype sum output very quickly.
If you do decide to organise your data as a table you can still keep a nice friendly looking grid of 6 team "tables" (different from Excel's use of the word) as a data entry facility to enter each month's scores by employee and task. You will need to find a way of getting each month's data from the data entry "tables" to the main data table. (Easiest way would be to use a bit of spare worksheet under the data entry tables to reproduce the entered data as a series of observation rows and then use Paste Special Values to append these rows to the end of the main table of observations. You can use VBA to automate the copy/paste operation if you want, you just need to figure out a way of identifying how may observations are currently in the main table and precisely where you want the paste to end up - COUNT() or COUNTA() is a useful friend here). Main problem to avoid (whether automated or not) is to avoid appending same entered data more than once to main data table.
Have a look at http://www.mediafire.com/download/x64swkp689k10a1/DataEntrytoTable.xlsx for a simple example of some of the above thoughts

Resources