Use particular formula based on referenced value - excel

I am working on creating a price list that uses calculated values to determine the price based on cost of good sold, area, and a few other things for some items.
There are different formulas used depending on the item type.
For example, prints would be calculated with an AREA multiplier type using the equation [#Multiplier]*[#Area] (referencing formatted table values, but they could also be typical references (f2*g2 for example)
So my question is, how could I set it so that a lookup of the multiplier type will reference a table that has the formula needed for that calculation.
I figured something like vlookup, but that either displays the equation itself, not the result, or doesnt work at all.
Currently, I have a big IF statement that works, but is a pain if I want to change the formula.
=MROUND(IF([#Mtype]='Multipliers 2'!$V$4,'Multipliers2'!W4,IF([#Mtype]='Multipliers 2'!$V$3,[#Multiplier]*[#Area]+40,IF([#Mtype]='Multipliers 2'!$V$5,2*[#[Cost of Goods]]+[#Multiplier], IF([#Mtype]='Multipliers 2'!$V$6,[#Area]*[#[Cost of Goods]]*[#Multiplier],[#Multiplier])))),0.5)
To Clarify, each product will have a multiplier type, along with data associated with the product that will be used for calculations:
So if I mark a product to use calculation A, the program should go look in a formula table, figure out what Calculation A is and then use those values to determine the result. If Calculation A = (Multiplier + 2*cost of goods sold), then it will look up the value in the multiplier column and add it to 2 x COGS.
Calculation B may be Multiplier * COGS and so on.
A problem I had last time I tried this a while ago was that even if I were to get the value to return some sort of result, I couldn't get the reference to change properly to correspond to the required row.
The data above is a small sample of what I'd be doing. Each product is part of a product type which has multiple variations in size, etc. So each product would reference a multiplier table which is used to calculate the final price, so if I want to change the prices for the entire group, all I'd have to do is change the value in the multiplier table, or the equation, and every corresponding product adjust accordingly.
The mtype would be controlled by the multiplier table. So I would like to set it so that if a particular mtype is used, the final calculation in the Price column will be determined by the formula listed.

Related

Excel Pivottable Subtract Two Columns

I am trying to figure out how to find net growth in a workforce in a pivotable. As of right now, I have a column that says status and consist of "Hire" and "Separation". I have these both in the pivotable as count of. For example, it could say 6 hire and 2 separation. However, when I do subtotal to see the net growth, it shows these two values added not subtracted. I need it to do subtotal of "hire" count - "separation" count.
Does anyone know how to do this? I know that inserting a calculated field will not work as you cannot calculate a field based of the value of another column
You can accomplish this a little differently, by not using subtotals. Instead, drag Status to your value field twice. The first will show you the number of hires and fires. Then, click the second Count > Value Field Settings > Show Values As. Choose Difference From in the dropdown. Base field is status and Base item is previous.
This will add a second column showing the Net Growth (or loss) of each grouping.

How do I use PivotTables to sum a variable, but where rows are repeated for subclasses?

Here, I have some vehicle data, attached with some corresponding information about the where the owners of these types of vehicles live, and their average house price.
Clearly the house price/location doesn't directly affect the vehicle value, but is useful for statistical inference.
What I want to do is to create a pivot table - however when considering the average vehicle value, the pivottable sums up each type of Vehicle/Model class multiple times as shown below:
And so, while the average House Price column in the pivottable is correct, the vehicle value is incorrectly counted multiple times (with respect to the Vehicle Make).
No, there is no DistinctSum function in the pivot table. The only thing that comes to mind is to add an additional column in the base table where the required values can be calculated. For example, in the column 'Distinct value' you can insert the following formula:
=D2/SUMPRODUCT((A2=$A$2:$A$13)*(B2=$B$2:$B$13))
it calculates the Value / Count of values for each car and model and then in the pivot table sum this column.

Different aggregation functions for different dimensions in Excel pivot table

Can I define different aggregation methods for subtotals in different dimension in an Excel pivot table?
The following example shows a result I'm trying to obtain. The metric to aggregate is, let's say, lines of code of a software project. The 2 dimensions in question are Date and Organization. In source data, Organization is broken down into 2 columns, Department and Project, while Date is a single column and Excel makes up the Months/Years summaries automatically when making the ODBC data connection.
A metric such as this one should be aggregated differently along the different dimensions. For the Organization dimension, the subtotal for all projects of the department is the SUM, but in the date dimension, the subtotal for all months of the year is the MAX of any given month (or perhaps AVG, or last etc. but certainly not SUM).
I've tried to define the different aggregation methods in Excel in the field settings, but it always selects one or the other method for both dimensions. Is there a way to do it, preferably using standard Pivot Table mechanisms or at worst a UDF in Excel?
What I would do to tackle this problem is to add both aggregation functions: sum and max , then hide ( or shrink a lot ) those columns you do not want to display.
in the above example I shrink columns B,D,F and I because of they has values that are out of scope for your requirements.
The "Total Max of Loc" displays a value consistent with the function expressed throughout the entire column: that is "the maximum number of lines of code reached by each project in each department; this could lead to misunderstandings when we observe the values of the subtotals and grand total; i.e: The "Grand Total - Total Max of Loc" is not the "Total Max of Sum of Loc": in the example, it shows 18 which represents the absolute maximum value of Loc in a Project in each Department; In the same way the Total Max of Loc for Department 2 is 18 and form Department 1 is 12
When requested a different behavior as expressed in comment to this answer, I think we are entering into the strong customizations space and some solution could be found by writing custom macro and by leveraging the getpivotdata function or, if it can be acceptable for your case, simply by the addition of a new column with the max()formula and possibly hiding the column "Total Max of Loc"

Ranking function

I am looking for some help regarding ranking. My spreadsheet has columns labeled as follows:
Tickers
P/E Rate of Change
P/B Rate of Change
Dividend Yield Rate of Change
P/Sales Rate of Change
I am looking to come up with a composite ranking that takes into account a tickers relative rank within each rate of change category. I tried this first by creating an additional 4 columns and using the formula as follows:
IFERROR(RANK(D4,$D:$D,1),"")
I believe this gives me a rank for the corresponding rate of change. However, for those cells that have either a blank or an error I want to use a median in calculating the tickers rank. I was then going to sum the ranks in another column to come up with my final ranking but that doesn't seem to be calculating correctly as I have blank rows returning rankings that don't make sense.
I think you are almost there.
For one column I would change what you have to
=IFERROR(RANK(D4,$D:$D,1),MEDIAN($D:$D))
Then simply expand to add all ranks together
=IFERROR(RANK(A4,$A:$A,1),MEDIAN($D:$D))
+IFERROR(RANK(B4,$B:$B,1),MEDIAN($D:$D))
+IFERROR(RANK(C4,$C:$C,1),MEDIAN($D:$D))
+IFERROR(RANK(D4,$D:$D,1),MEDIAN($D:$D))
+IFERROR(RANK(E4,$E:$E,1),MEDIAN($D:$D))
To avoid potentially large numbers you could use an average (same resulting rank, but potentially easier to understand) by slightly changing the formula to:
=(IFERROR(RANK(A4,$A:$A,1),MEDIAN($D:$D))
+IFERROR(RANK(B4,$B:$B,1),MEDIAN($D:$D))
+IFERROR(RANK(C4,$C:$C,1),MEDIAN($D:$D))
+IFERROR(RANK(D4,$D:$D,1),MEDIAN($D:$D))
+IFERROR(RANK(E4,$E:$E,1),MEDIAN($D:$D)))/5

Picking top 5 scores from a range

I run a small golf eclectic with excel. One of the things we have is a points system. I would like to get the 5 highest points scored over the season and have them ranked from 1 (being the highest points scored) to 5.
My knowledge of excel "sums" goes only a wee bit further than add and subtract.
Thanks!
If you don't want to change the order that they are presently in you can use the LARGE function. It returns the kth largest value.
Below is a great formula, if you drag it down it will automatically get the second, third and nth largest value from a table of data (in this example the data is between A1 to A10).
=LARGE(A1:A10,ROW(A1)-ROW($A$1)+1)
You can then match the values with names or corresponding data from the tables using the MATCH and INDEX functions. The example below would fetch the name for each value from the second column.
=INDEX($A$1:$B$10,MATCH(cell reference with score or value,$A$1:$B$10,2))
Play around with these formulas, they are very convenient for data m
If you have a column containing the scores, you could add a filter (Data->Filter I think) and sort descending.
Though, if you just have rows that are something like [Date][Person][Score] you'll need to go to another sheet and SUM the scores for each person then sort that... Unfortunately my Excel skills aren't up to par to pull a score for each person like that.
Given a list of numbers in A1 to A10, you can work out their 'Rank' relative to each other by using 'RANK'.
e.g.
RANK(A1,A1:A6,0)
RANK(cell, list of cells to check against, order)
For order, 0 = descending.
From there you can work out which one is first pragmatically.
If you have Excel 2007,
Check that your data is continuous, with no blank rows or columns. Click on your scores and then select 'Data - Filter'
Using the dropdown that the filter creates at the top of your scores column and select 'Number filters - Top ten'
A 'Top ten Autofilter' dialog will be displayed, reduce the show 10 to 5 and then click on OK.
For earlier versions of Excel add a RANK formula in a new column. Be careful as the scores need to be sorted, usually into descending order. If there are any ties, they will be given the same ranking number and the subsequent rank number will be incremented by the number of ties. (E.g. If there are two scores of 2, ranked as 5. The next score will be ranked as 7, not 6)
If you want to use the LARGE Function as described above, make sure you put the same range in the list for each of the LARGE functions. That is, change =LARGE(A1:A10,ROW(A1)-ROW($A$1)+1) to =LARGE(A$1:A$10,ROW(A1)-ROW($A$1)+1) or you will get some strange incorrect results

Resources