Pivot table and manual correction in excel - excel

I have a pivot table, from a data source which contains false values for a specific date.
Some people in my department provided with the correction of the agregated numbers.
Do I have a way to insert a manual correction just for this cell point or is the only way to copy by value etc....?

I believe correcting the source data is your best option. Of course the best thing would be if they could give you the corrected individual data points.
If you can't get that, then I think you need to add a helper column to the source data that will contain corrected numbers that you calculate based on the ratio between the incorrect aggregate and the correct one:
In this example, to the right I've calculated the ratio between the incorrect and correct aggregates. Column C is the new helper column. It contains a formula with an IF statement that checks the date. IF it's the date with the problem it multiplies each individual amount by the Correction Ratio in G2. You can then change your pivot table to use Column B instead of Column C.
It's important to to note that Column C now contains incorrect data by row. So again, stating the obvious, the best thing would be if they give you the detail data!

Related

Dynamic GETPIVOTDATA formula to SUM with different date ranges per column

I have below an example pivot table with Countries as my columns, and Dates as my rows. The data for this pivot is based on A1:C13. Cells F1:G3 is what the user of this model can adjust. They can change the country and/or the date ranges.
What I am needing is a single formula to output the total of their selection. As my actual data set contains many countries, simply writing an nested IF statement won't suffice. The dataset also needs to be in pivot table - hence the GETPIVOTDATA requirement.
I've gotten about half of the way there using this formula here:
=SUM(GETPIVOTDATA("Sum of Value",$A$15,"Date",ROW(INDIRECT(F2&":"&F3)),"Country",F1:G1))
The problem here is that this formula is not dynamic for the differing date selections per country.
Can anyone assist?
You need a separate GETPIVOTDATA for each country:
=SUM(GETPIVOTDATA("Sum of Value",$A$15,"Date",ROW(INDIRECT(F2&":"&F3)),"Country",F1),GETPIVOTDATA("Sum of Value",$A$15,"Date",ROW(INDIRECT(G2&":"&G3)),"Country",G1))
The answer provided by #basic is the closest one for the original question, i.e. using GETPIVOTDATA to work out the total per given parameters.
If the calculation can be done on the original data table (Range A1:C13), then here is another solution to calculate the total.
=SUMPRODUCT((A2:A13=F1:G1)*(B2:B13>=F2:G2)*(B2:B13<=F3:G3)*(C2:C13))
In order to make the above calculation "dynamic", i.e. the calculation updates as the rows expands in the table, you can put the source data into a Structured Reference Table, give a Name to each column, such as "List_Ctry" for Column A, "List_Date" for Column B, and "List_Value" for Column C, then the range behind each name will update automatically when the source data changes. Using these names, the formula will be something like:
=SUMPRODUCT((List_Ctry=F1:G1)*(List_Date>=F2:G2)*(List_Date<=F3:G3)*List_Value)
You can also give names to the three parameters, being the range of country, range of start date, and range of end date. I will not illustrate further as if you understand the above concepts, you should be able to do this step yourself.
By using Name in the excel workbook, it will enable you to refer to the source data conveniently without the need to lay it out in your final report, so I do not understand what is the limitation here to stop you from calculating from the source data but have to work on the pivot table, as the calculations on pivot table are limited and not that intuitive.
Feel free to let me know if you have any questions :)

How to refer to an Excel table column by name when table changes over time

Short question: Is there a way to get a formula that references a column in an Excel table to always refer to only the column with that name? This is a straight-up formula question, not VBA-related.
Formula:
=COUNTIFS(Table35[[dc]:[dc]],$A6)
In this case column A has a data center name in it. Table 35 is the output of another program that produces data for an ETL and also most of the same data for this spreadsheet that is used for both analysis and status reporting.
Problem
Due to the nature of analysis, the shape of the data changes. It seems like about once a week there is another variable (column) that needs to be added to the ETL and analysis. I've simply been copying the program output, going to the upper left hand of the table and pasting. For all of my PivotTable analysis of this data it works exactly the way I want it to.
The problem happens to my dashboard built with various Countifs() formulas like the one above. My initial expectation of behavior is that by referencing the data (first by column name and now as a range of columns that contain only one column of data) that Countifs() would select the data based on column header value (much like using vlookup() + match() together).
Instead what happens is that when a column gets added the names in all of my formulas change. It appears the internal representation essentially says I want column #N. No matter what data happens to be in column N, that is what shows up. So for example, [dc] above turns into [CS Windows Error Message]
Is there any way to indicate that I want the column named "dc" regardless of where in the table dc is located? Even the great and omniscient Google has failed me on this one. Help appreciated.
Try wrapping the table reference into the Indirect function. That will preserve the column name and return the correct value.
=COUNTIFS(INDIRECT("Table1[dc]"),2)
or, with your formula
=COUNTIFS(INDIRECT("Table35[[dc]:[dc]]"),$A6)

Is there a way to see if a given value exists in a row identified via VLOOKUP and, if so, return the value in another cell in that row?

I have an Excel data set that summarizes shipping surcharges by tracking number. I have the tracking number in Column A as my Index, but the data is presented such that to the right of the tracking number in Column A, I have pairs of columns that dictate Charge Type and $ Charge to the right of the tracking. The column Headers are generic for the Surcharge Type and Surcharge Amount, so the columns are not fixed. As such, Column B (the first Surcharge Type for any given tracking number) could either be blank OR contain any of a subset of applicable tracking surcharges, with the charge amount associated with that surcharge type being presented in Column C (otherwise it is $0). I want to recreate the data set with my tracking numbers in Column A, all of the possible surcharge types fixed as the column headers (beginning in Column B), and the body of the table containing only the charge amounts, in $, for a given combination of tracking number and surcharge type.
See current format and desired format as follows.
Current:
enter image description here
Desired:
enter image description here
How can I most efficiently code this in Excel?
Now, what if I tell you that a given tracking number can show up more than once in Column A (i.e. adjustments to prior charges). How does this change the formula?
THANK YOU!
The following formula might work:
=IFERROR(INDIRECT("<sheetname>!"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),MATCH(<columnHeader>,INDIRECT("<sheetname>!"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),2)&":"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),<max#ofSurcharges*2+1>)),0)+2)),0)
It essentially finds the row of the tracking # on the first sheet and creates an array in which to search for the surcharge name and if it finds the surcharge it will return the value of the adjacent cell, which is the associated value.
Please note that this formula is somewhat dependent on the structure of the raw data: tracking numbers must be in column A and the surcharges need to start in column B.
Also this will only find the first instance of the tracking number in the list, so I suggest adding some form of timestamp to sort your raw data, if you need to use the latest entry.
Edit: a solution using VLOOKUP might be more efficient, not sure
Edit2: The problem with VLOOKUP is that the raw data is no proper table like the edited data. Really the best solution would be to enter 0 values in the first place, not afterwards.
Anyway, this solution is fairly similar to the above, but uses VLOOKUP to retrieve the data in the end. If you are dealing with large sets of data you can test which method is more efficient.
=IFERROR(VLOOKUP(<Tracking#>,<referenceToRawData>,MATCH(<columnHeader>,INDIRECT("<sheetname>!"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),2)&":"&ADDRESS(MATCH(<Tracking#>,<sheetname>!$A:$A,0),<max#ofSurcharges*2+1>)),0)+2,FALSE),0)

Calculate average of values in a column based on matches of two variables in two other columns

I'm having an issue with some data that I'm working on that has had me stuck for a while.
I'm working on some patient data for a clinical practice that has each patient encounter logged on a separate line with an account ID, date of service, the height and weight measurements for that date, and other variables.
Aside from VLOOKUP and the usual formulae/functions I've got a pretty rudimentary understanding of Excel but I can pick up on things fairly quickly.
In the data I've got each line tied to a patient account ID as well as what quarter the DOS was in. For patients with multiple visits, they will be identifiable by repetitions of the account ID number on other lines.
For some patients, there will also be repetitions in the quarter if the same patient was seen twice in the same quarter. This is where I need help.
I'd simply like to average the value of a variable for each patient in each quarter. I'm not sure if AVERAGEIFS is the right function to use but I need an operation that checks for matches in a line of both account ID and quarter (Q1, Q2, Q3, or Q4) with the other lines in the sheet and comes up with a quarterly average for the variables in question.
What I have
What I need
If I'm understanding your question, you could use AVERAGEIFS to accomplish what you are asking. With excel, a lot of how successful an approach will be is determined by how your data is structured, and if/how often you are planning on updating your work.
It would be easier to give a concrete answer with an example of the data you are looking at.
If your source data is in columns A:D something like:
and you are looking to summarize the weight data in I by account ID and Quarter:
you could use AVERAGEIFS(C:C,A:A,G2,B:B,H2) this would find the cells in column A that match the value in G2, find the cells in column B that match the value in H2, and report the mean value in column C of the matching rows.
An alternative is to use a pivot table, which automates a lot of what you are trying to do. For that approach you would select your data block, and click on Insert>>Insert Pivot Table (at least in my version). That should bring up a wizard. Accepting the defaults will create a new sheet. Then look on the right side of your window, and you should see a list of your column names near the top, and four boxes called Filters, Columns, Rows, and Values. You should be able to drag and drop your columns into these boxes to get summaries of your data. If you add your Account ID and Quarter tabs as columns, and your height and weight as Values, then right click on each of the value columns and select "Value Field Settings" and select Average from the menu that pops up. That should give you something that looks like:
At that point, you can change the formatting to make if fit your needs, or copy data somewhere else.
The AVERAGEIFS approach will automatically update if you add more data, but will only summarize things that match the values you list. If there is an account ID/Quarter pair that isn't in the summary column you won't have any idea it's there. If you are summarizing an ID/Quarter pair that isn't in your data you'll end up with a division by Zero error like in the example.
The Pivot Table option only updates when you manually click refresh (right click and choose refresh pivot table from the menu), but will summarize all the data based on the columns you've selected. It's also a little more robust as you avoid having to type out the formulas and make sure you are pointing to the right column. This option also by default provides nested summaries; you can turn the subtotals and grand totals off if you want.
I used the function:
=SUMPRODUCT(($B$2:$B$13="Customer 1")*($C$2:$C$13="Q1"))
Where Customer 1 could be a user id and Q1 you can change to which quarter you want.
Excel screenshot

How do I populate a cell based on its value from a range?

Hello,
Please forgive me if I didn't word my question very well. However, I have an excel spreadsheet that I must complete and submit to our headquarters on a monthly basis. I've been manually editing most of the fields but I think there's a way to automate some of the values. Unfortunately, I haven't figured it out yet so I thought I'd seek help here.
So I have two tables (Table1 and Table2) - images below. What I need is a way to automatically populate the RATE FACTOR (Column D) if the WEIGHT (Column C) falls within a certain range (defined in table2).
I was reading on here about using VLOOKUP, but couldn't get it to work. Any assistance would be appreciated, thanks.
IMAGES BELOW (had trouble attaching images to question).
Table 1: https://dl.dropbox.com/u/55292384/table1.jpg
Table 2: https://dl.dropbox.com/u/55292384/table2.jpg
//Kismet
Assuming that your example has the titles in row 1, in cell D2 enter =VLOOKUP(C2,$G$2:$H$17,2)
You can copy this formula to the other cells in column D.
VLOOKUP demands that the table of values is sorted in ascending order by the first column. The lookup value (here C2) is found in the first column and the 2 says to return the corresponding value in the second column. By default if the lookup value is not found, VLOOKUP returns the result corresponding to the nearest value less than the lookup value. This may or may not suit your rate factor calculation (if not, I can make an additional suggestion).

Resources