How to customize the grand total from sum to percentage of a column 1 without changing the values in column 1?
For Example:- I have a data
Required output should be :-
Grand total of column value 1 = (value 1/ value 2)*100.
You can create a different column with the formula (value 1/ value 2)*100.
You will then need to unpivot/pivot things to get the data in the format which has Dove, Loreal, etc and the new calculation as columns. So you will be able to easily plot them in a matrix.
I won't call this as a solution, but I think this is the most efficient workaround. Let me know if it helps in any way.
Related
I have a question. I'm collecting social media statistics (likes, shares, comments, etc.), and one thing that I'm trying to do is get Excel to tell me the date that the largest number of hits occurred, what post it was on, and what type it was.
I'm part of the way there--I can get Excel to tell me what the highest number is (MAX, easy!), but I can't get it to lock in the date properly.
The way I've got it set up is: there's a single row for each day of the month, with the dates in column A, and additional columns for the types of engagements I'm tracking. At the very bottom of the table is a row with all the MAX values from each column (so in other words, column B will have Likes, column C is shares, and so on, so I can enter a new value for each analytic every day.
Essentially, what I'm trying to do is get Excel to do this, in order:
Look along the row with all the MAX values to find the highest value;
Look up above that (same column) into the data rows until it finds that MAX value;
Take note of the row where it found that MAX value, and return the value of the date from Column A
Make sense? I've got a formula set up with INDEX and MATCH, but while it is giving me the correct numbers for the top value and what type of analytic it is, I can't seem to get the correct date (what it looks like it's doing is counting the columns from left until it finds the value for #2, then counting that number of rows down).
Can anyone help?
You can do this by nesting MAX, MATCH and INDEX
Mockup of your data
The Formula
=INDEX(Table1[Date], MATCH(MAX(Table1[#Totals]), INDEX(Table1, , MATCH(MAX(Table1[#Totals]), Table1[#Totals], 0) ), 0 ) )
Explanation of the Formula
Of course, you don't have to use a Table. A formula for the same data, without Structured References
=INDEX(Sheet1!$K$2:$K$10, MATCH(MAX(Sheet1!$K$11:$P$11), INDEX(Sheet1!$K$2:$P$10, , MATCH(MAX(Sheet1!$K$11:$P$11), Sheet1!$K$11:$P$11, 0) ), 0 ) )
I am doing quotations in Excel for my company and I am trying to find a way to do 2 things:
aggregate several quantities of the same product based on its reference number
return several values for the same references (i.e. different prices)
I was thinking about using VLOOKUP but I cannot find a way to make it sum or return multiple values.
Table outline in the picture attached here, the wanted result would be:
- for the 1st function: sum up the table into 3 lines with aggregated quantities for products X Y Z
- for the 2nd function: sum up the table into 4 lines with the prices for products X Y Z (X having 2 different prices in the sample data, but I would need the function to be able to return as many lines as there are different prices for the same product)
Thank you very much for you help!
Kind regards,
Antoine
Edit: to get a better idea of what I try to achieve, here is another picture:
2nd pic with annotations
Quantities of the same product have to be aggregated, except if the unit price is different.
Could price difference be based on a subreference to be added to the first table? That would need the vlookup to match 2 values to return a result, is that feasible?
Noting that I do not have control over the source data for unit price, meaning that reference and subreference would have to be in different columns rather than concatenated.
The goal is to produce a recap table rather than filter out single values as suggested in the answer.
So, try this:
Cell B10 is the product you want to look at then G2 is the test if the product on that row matches. Finally, the sumproduct calculates the total, but you can change which column it looks at, I just chose the total column.
Now showing use of data validation from a list:
I'm looking for a solution that would give me a weighted average based on a dynamically filtered table. Here is what I have:
Column A: a list of urls,
Column B: numbers,
Column C: percentages
/page 100000 20%
/brochures.htm?en 27443 75,30%
/brochures.htm?fr 1656 67,33%
/brochures.htm?it 483 75,00%
/brochures.htm?fr-fr 6 0,00%
What I want, is a formula that give me the weighted percentage of the pages that start with "/brochures/htm", which is in this case: 74,83%.
I am able to do it in two times with an intermediate sheet where I filter the table with
=FILTER(A1:C5;REGEXMATCH(A1:A5;"/brochures.html*"))
then in the third sheet by calculating the weighted average with
=SUMPRODUCT(C1:C5;B1:B5)/SUM(B1:B5)
, but as you can imagine it is not a good solution for my needs.
Anyone can help? I've created a google sheet so you can easily understand how I get to that 74,83%.
-> https://docs.google.com/spreadsheets/d/1Q-ydRSOdoGN2wVj7Z4XWglz-0U7pL3_xMeyGdRB2K84/edit?usp=sharing
For Excel. You could use an array formula to achieve this. Make sure to use Ctrl + Shift + Enter instead of just Enter after typing out the formula
=SUMPRODUCT(IF(LEFT(A1:A5,14)="/brochures.htm",B1:B5,0),C1:C5)/SUM(IF(LEFT(A1:A5,14)="/brochures.htm",B1:B5,0))
I tested this with your sample data above in Excel and it came out with 74.83%. I hope this helps
For Google sheets this will work:
=ArrayFormula(SUMPRODUCT(IF(LEFT(A1:A5,14)="/brochures.htm",B1:B5,0),C1:C5)/SUM(IF(LEFT(A1:A5,14)="/brochures.htm",B1:B5,0)))
or use semicolon ; instead the coma , if your local setting are different from the US.
I believe, this formula would help (Google Sheets only):
=QUERY(QUERY(QUERY({A3:C8};"select 'avg', Col2*Col3, Col2 where Col1 like '/brochures.htm%'");"select Col1, sum(Col2)/sum(Col3) group by Col1");"select Col2 Label Col2 ''")
First query selects Col2*Col3, Col2 when conditions are met: Col1 like '/brochures.htm%'
Second query
finds the weighted average of a filtered table
Third query
gets only the resulting number from the second query
In your sample:
https://docs.google.com/spreadsheets/d/1Q-ydRSOdoGN2wVj7Z4XWglz-0U7pL3_xMeyGdRB2K84/edit#gid=1380706652
The benefit of using this formula is that you have to reference the data only once, and also you have more setting tools with query formula.
I would like to know how to add a weighted average in my pivot table. In fact, I need to do the following calculation: SUM(col1 * col2)/SUM(col2).
I tried to do it by using the calculated field option but when I enter my formula, I just have the following result as an output: SUM((col1 * col2)/col2) which is equal to SUM(col1).
You will need 1 calculated field, and 1 helper column
Helper Column
col3=col1*col2
Calculated field:
CF=Col3/Col1
If you try to do the helper column as a calculated field, it will sum col1 and col2, then multiply them together which results in a meaningless answer
Given you are after the Excel Pivot table version of a weighted average, I think you might find this article useful:
http://excelribbon.tips.net/T007129_Weighted_Averages_in_a_PivotTable.html
The only thing it doesn't mention is what to do if your weighting sums to zero (in which case you will divide by zero). To avoid that ugliness you can use your Pivot table's DisplayErrorString and ErrorString properties, e.g.
oPivot.DisplayErrorString = True
oPivot.ErrorString = "--"
Though obviously that may hide real errors elsewhere in your Pivot table.
Try to use
=SUMPRODUCT(A1:A6, B1:B6)/SUM(B1:B6)
This article may help you: Calculate Weighted Average in Excel by Ted French
Lets say I have an Excel sheet such that:
Column 1 contains salaries
Column 2 contains gender (M/F)
How can I calculate the average salary for females?
=AVERAGE(IF(B1:B10="F",A1:A10))
entered as an array function (ie using Shift-CTRL-Enter rather than just Enter)
Allthough the answer is already answered/accepted I can't resist to add my 2 cents:
Sums and averages normally are displayed at the bottom of a list. You can use the SUBTOTAL() function to calculate sum and average and specify to include or exclude "hidden" values, i.e. values suppressed by a filter. So the solution could be:
create a formula =SUBTOTAL(101,A2:A6) for the average
create a formula =SUBTOTAL(109,A2:A6) for the sum
create an autofilter on the Gender column
Now, when you filter for "F", "M" or all, the correct sum and average will always be computed.
Hope that helps - Good luck
To do it without an array formula just use this:
=SUMIF(B:B,"F",A:A)/COUNTIF(B:B,"F")
Answered question, solid formulas - BUT - beware of conditional averages based on numbers:
In a very similar situation I tried:
"=AVERAGE(IF(F696:F824<0;E696:E824))" (shift control enter) - In English this asked Excel to calculate an average on all numbers in column E if a result in column F was negative (a loss) - e.g. "calculate an average for all items where a loss occured". (no circular reference)
When asked to calculate an average for all items where a gain (x>0) occured, Excel got it right. However, when the conditional average was based on a loss - Excel produced a huge error (7.53 instead of 28.27).
I then opened exactly the same document in Open Office, where Calc got the (correct) answer 28,27 from the same Array formula.
Recalculating the whole thing in steps in Excel (first new column of only losses, new for only gains, new column for only E-values where a loss/gain occured, then a "clean" (unconditional) average calculation, produced the correct values.
Thus, it should be noted that Excel and Open Office produce different answers (and Excel 2007, Swedish language version, gets them wrong) in some cases of conditional averages.
(sorry for my long cautionary tale - but be a bit careful when the condition is a number would be my advice)
You can put filter in top line of your sheet. Then Filter only Fs from Column2, then calculate average of values.
Or you can add additional column with female salaries only.
The formula would be like: =IF(B1 = "Female";A1)
Then you simply calculate average of newly created column.
Salaries gender
2500 M 0 2500*0
2400 F 1 2400×1
2300 F 1 2300×1
sum =2 sum=4700 average=4700/2
Maybe it be complex.