I'm working with excel 2016. I have some unstructured data as in the screenshot. I would like to group the rows by zip code , then calculate the average of all the values in each zip code. I'm pretty new to excel. Is there a function or group of functions which can do this?
Given your table of data, to determine the zip avg price/acre you can do a weighted average.
for each zip, divide the total sales price by the total acreage
I changed the data into a Table so as to be able to use structured references; but you can change that to regular addressing if you prefer.
The formula for doing the weighted average:
=SUMIF([ZIP],[#ZIP],[price])/SUMIF([ZIP],[#ZIP],[acres])
Note that if you calculated the average of the price/acre for each zip code, you would be computing the Avg Price/Acre/Sale, not the Avg Price/Acre. For zips with multiple sales, the difference can be substantial
=AVERAGEIF([ZIP],[#ZIP],[Price/Acre])
If you just want to show the zip and the avg price/acre, you can use a Pivot Table:
Drag zip => rows area
Create a Calculated Field with the formula =Sum(price)/Sum(acres) and drag that to the Values area
And, of course, if you should want the avg price/acre/sale, drag the Price/Acre to the Values area, and choose to summarize by average.
Related
Please help,
I want to calculate the actual downtime per each type of equipment and per each type of work order, as shown in the following table sample of the data which extend in real file to 6000 rows:
Data table
, when I use this formula:
{=SUMPRODUCT((COUNTIFS(K2:K6000,"<"&MIN(K2:K6000)+ROW(INDIRECT("1:"&ROUND((MAX(L2:L6000)-MIN(K2:K6000))*1440,0)))/1440-1/2880,L2:L6000,">"&MIN(K2:K6000)+ROW(INDIRECT("1:"&ROUND((MAX(L2:L6000)-MIN(K2:K6000))*1440,0)))/1440-1/2880,G2:G6000,"*"&P3&"*",A2:A6000,"PRMN")>0)+0)/60}
I take a long time to calculate as I use it for 6000 rows with extra 2 criteria, so how I can improve this formula to be faster?
Best Regards,
Mahmoud Hazem
Overall goal for my report:
I am creating a pivot table in excel right now (eventually in Power Bi) that will update daily through data imports to reflect weekly changes in sales. I am then trying to perform a Z score analysis on each week to see if there are any outliers within the data.
What I will need to do is be able to subtract a mean of all of the data from each weekly set of sales, then divide it by the standard deviation.
Current thought process for data:
If I can get the grand total at the bottom, could I get that as a value entered for each row in another column? Can I do it as a total average and a total standard deviation? I can do it outside of a pivot table, but I want something in a pivot table so it auto-populates.
Current Data
Desired Data
You can tackle this in at least two approaches:
Dynamic calculation using measures
Back-end calculation
The first approach consists of defining measures in the following context:
CALCULATE([MEASURES], All('Calendar'), VALUES('Calendar'[Year]), VALUES('Calendar'[Month]))
This allows you to calculate a measure in a context that consider the entire month. Therefore, for each day you would have a measure that gives you the stdev of the entire month.
Pro: dynamic; fast to implement; can be based on measures already defined
Cons: more calculation in front-end slows down your report
The second approach consists of pre-calculating this values in the back-end. Here you have two possible approaches:
Data source: add these new columns in the data source (e.g. Database)
Pro: best-practices and clean approach
Cons: static; cannot use measures already defined
Calculated Column in DAX: define the value as a Calculated Column in the back-end of Power BI using the same structured defined for the Measure:
CALCULATE([MEASURES], All('Calendar'), VALUES('Calendar'[Year]), VALUES('Calendar'[Month]))
Pro: fast to implement
Cons: static; really against best-practices
In Power BI I used following measures (replace 'stack' with 'your table name')
Total StdDev = CALCULATE(STDEV.P(stack[sum of sales]), ALL(stack))
TotalMean = CALCULATE(AVERAGE(stack[sum of sales]),ALL(stack))
Z score = (SUM(stack[sum of sales]) - [TotalMean])/[Total StdDev]
I used average to calculate MEAN and I get different result to yours (please see below).
If you can share formula that you used to calculate 'TotalMean' maybe I can update it.
I am new to PowerPivot within Excel, but am familiar with SQL.
I import a table from my SQL server into PowerPivot, containing the results of some surveys; the columns are: City, State, Population, avg income, avg income x population.
I need to create a Pivot Table showing the weighted average income by State.
If the source of the data were an Excel sheet, I'd add a calculated field to the pivot table, calculating [avg income x population] / [Population].
I cannot seem to that in my case, since the source is a PowerPivot data source.
Suggestions?
I understand I can add calculated fields and measures to the PowerPivot table, but that's not really what I am after.
I am sure it's because my google skills are subpar, but I have also spent lots of time searching for solutions, to no avail.
E.g. these discussions show how to add a field to the powerpivot source, but it's not clear to me how you add a calculated field to a Pivot table which reads from PowerPivot.
PowerPivot formula for row wise weighted average
DAX - 2 phased weighted average with 2 different weight measures
So I am trying to calculate the average cost of On-Hand goods in this example. The goal of this would be to determine the overall cost of goods by department. This would be achieved arithmetically by taking the average cost of the good and multiplying it by the number of goods on hand for that item, and then repeating for each item. I would then want to add items from the same numerical departments to get a department item cost. Is there a way to do this within a single function in excel? So far I have:
=IF($B$2:$B$17=F2,SUMPRODUCT($C$2:$C$17,$D$2:$D$17),"null")
but it is returning an invalid output.
For Cell J2, the output I would want to look for is: $74093.80
The reason I want to do this by function is because I have a spreadsheet with over 76,000 items and 19 different departments on it and need to calculate the Average Inventory Cost of each Department.
Thank you in advance!
Click here for Excel sheet
Put the test inside the SUMPRODUCT():
=SUMPRODUCT(--(B$2:$B$17=F2),$C$2:$C$17,$D$2:$D$17)
I'm trying to get the average number of "on time shipment" based on items rolled up to "ship numbers" and then by "order number". I have one order number in this scenario that is shipped via multiple shipments. It seems to me that after rolling it up via PowerPivot and then creating a pivot table, it's calculating the average based on the total lines of the "order number" instead the pivot.
PowerPivot Data:
Pivot based on data above:
How can I get the average number based on the pivot table rather than the PowerPivot total data of the order number? I'm probably not making any sense, but hopefully the images below explain it better. As you can see, when you roll up the items by ship number then by order number, you'll see that the actual average is 0.6 but the pivot is showing 0.5.
Help!
Technically speaking, the average is correct - if you look at the source data, for some reason all rows are duplicated and if you do regular average calculation, it's actually 0.5.
What you are looking for is calculating average for distinct values, which can be done easily with AVERAGEX function.
I have copied your table and created those 2 Calculated Fields (in Excel 2010, it's Measures):
Average on Time:
=AVERAGE(Table1[On Time])
Average on Time (UNIQUE)
=AVERAGEX(VALUES(Table1[Ship Number]), [Average on Time])
Using AverageX with VALUES() function makes it easier to calculate any expression ONLY for unique values.
If you then put both measures on PivotTable, you should get this:
First column is same as yours (using "regular" AVERAGE function). The second one shows the average calculated over distinct (unique) values of Ship Numbers.
Hope this helps.
PS: This great article by Kasper de Jonge helped me quite a bit with similar scenarios.