Finding the correct parameters in excel DB - excel-formula

I have a sheet with about 20 countries and 100 measures. I'm creating an interactive summary sheet. Been trying IF, AND and VLOOKup but unsure of which is best.
when you change country selection the corresponding fact should change. Eg:
Country x and measure y, look up correct value in data sheet z
Which is the best formula? Thank you!

It is not possible to give you an answer without better understanding your data.
For example, how is the data stored 'in data sheet z'?
If you have a table where Country X is in rows, with Measure Y in columns, and the value at the intersection of the 2, INDEX/MATCH/MATCH will be the best way to craft a solution.
Are you able to post a screenshot of the data, preferably with column headings, so that a more complete solution can be provided?

Related

Using XLOOKUP when dynamically assigning rank to a table does not pull the correct data

The issue I am having is trying to use XLOOKUP on a table column that has been generated using a ranking formula.
The Rank column is created using the following formula so that it adjusts dynamically depending on the visible columns (auto-filtering) since RANK.AVG or EQ does not take that into account.
=SUMPRODUCT(SUBTOTAL(3,OFFSET(Table2[[#All],[Sales]],ROW(Table2[[#All],[Sales]])-MIN(ROW(Table2[[#All],[Sales]])),0,1)),--([#Sales]<Table2[[#All],[Sales]]))
The XLOOKUP I am using is simple
=XLOOKUP(1,Table2[Rank], Table2[Rep])
The idea is that the field at the top would show the top ranked performer based on the visible rows. The problem is that when filtering the data, the rank column adjusts as it should, but the XLOOKUP does not function as I would expect. It sticks with the originally ranked 1 or even does something complete weird that I can't explain when running combinations of filters in the region column..
Anyone have any advice how I could better structure this to make it function in the intended manner. Any help at all would be appreciated.
You'll need to employ a similar construction to account for visible rows only, for example:
=LOOKUP(1,QUOTIENT(0,SUBTOTAL(3,OFFSET(INDEX(Table2[Sales],1),ROW(Table2[Sales])-MIN(ROW(Table2[Sales])),))*(Table2[Rank]=1)),Table2[Rep])
Not sure why you're referencing the table header row in your other formula.

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 :)

extract specific rows in a new sheet based on criteria

I have an excel file with hundreds of steps(one on each row) and each column represents a scenario. If that step is executed in the scenario there is a value "x" in the same row.
I would like to extract the data from this sheet to another sheet where for each scenario I would see just the steps executed in it. (a scenarios has a few steps).
Here is a representation of what I would like to do
I tried using advanced filtering function but it did not give me the results i would like and I am not very skilled at writing IF conditions. Any help would be appreciated.
Try this array formula in J3 if your data is as per my screenshot and drag it as required.
=IFERROR(INDEX($A$3:$A$12,SMALL(IF(ISTEXT(B$3:B$12),ROW($A$1:$A$10)),ROW(A1))),"")
You may try to use a pivot table, where rows are the steps and columns are the scenarios. Use scenarios as values and using the count instead sum.
That way you can later on the output sheet use de getpivotdata to fill it.

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).

Pivot table and manual correction in 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!

Resources