powerpivot 2016 - Divide summed value column with grouped raw value - powerpivot

I’ve got about 1 million records to perform the following calculation, which I was not very successful so far. I appreciate if you could point me to the right direction.
What I’m trying to do is write measures or calculated fields to:
divide the summed field from a value in the grouped raw.
Get the quotient
Get the mod
Calculate price
Display the grand total at the bottom
Example file: https://1drv.ms/x/s!AkN0kHWepnYzgSujfvGKA15fEygW
Appreciate your help

Related

SQL - Finding Percent Of a Total and subtracting to get two new totals

In my SQL course I'm trying to answer a problem in which i'm being asked to find X% of a Total then subtracting that result from the original total to produce another result. Then putting these results (the X% of the total and the total-X% of total) in two new columns.
Example: We need to know how much money we owe Tom and Ted. We have total up sales to $1,000,000.00. We owe Tom 75% of that total. The remainder goes to Ted.
I can't seem to find anything in my readings/videos about this nor a google search that isn't an answers that produces ratios or comparing to other records in the table. Also, not sure about how to get the results into their own columns. Thanks for any advice!
Example of what I got so far:
SELECT SUM(Sale_Amount) From Order_Table
Now I have to find the % of that SUM then subtract it from the SUM and push both results to two new columns, one for the percent of the SUM(Sale_Amount) and one for the remainder.
Given it's an SQL course (and it's not 100% clear what's being asked), I'm not going to give you the total answer, but I'll give you components but you'll need to understand them to put them together.
In SQL, you can
Get totals using SUM and GROUP BY
Do normal maths e.g., SELECT 10000 * 60/100 to get percentages of totals
'Save' results by a) having columns/fields to save them in, and b) UPDATE those fields with relevant data
Note if you're not saving data, and simply reporting them, you can just add those to a SELECT statement e.g., SELECT 100000 AS Total, 100000 * 0.75 AS Toms_Share, 100000 * 0.25 AS Teds_Share.

Average 3 rows that contain mm:hh:ss

In my table I have 3 colmuns
T1 T2 T3
I want to average the time in all 3.
My query in design view is set as follows:
Score: Avg([swim]+[bike]+[run])
In total, I have it done as an expression.
When I run the query an example result shows as: 8.81406810035843E-02
Any ideas how I can get it to show the average time over all 3 correctly?
I have also changed the format to hh:nn:ss - The results looks better but not correct
I hope you are looking for this
Score: Avg(([swim]+[bike]+[run])/3)
Using the Avg() funciton, you are making average of every time in column. Adding them together, the resulting time is too huge to show for access. When you average something in one row, you have to add it up and then divide by number of each member.

Sum all fields from lookup SSRS [duplicate]

If i take a 4 day period it only shows capacity from the latest day, but I need to show the total capacity over 4 days. I try to sum the capacity wich is a lookup that looks like this:
=Lookup(Fields!ID.Value,Fields!Name.Value,Fields!capacity.Value, "table_1")
It does not work if I just add a Sum() in the beginning and I've tried to solve it with Code.Lookup_Sum but lookup_Sum gets red.
This is what I am trying to accomplish:
How can I do that?
Count Capacity in the QUERY as total Capacity

How do I compute an average of calculated averages in MS reportviewer/rdlc?

I've searched here and elsewhere on the web and have not found this exact problem/solution.
I'm building an rdlc report using the MS reportViewer - the report I'm creating is based on an existing spreadsheet where the average price across 6 months is calculated individually for each month, then the average of those prices is calculated as the 6 month period average price. Whether I agree with that methodology or if it's correct is irrelevant, I just need to know how to get an rdlc to do this.
For example:
Month Price1 Price2 Delta
May-12 $31.54 $30.03 $1.51
Jun-12 $36.27 $34.60 $1.67
Jul-12 $44.19 $42.00 $2.19
Aug-12 $38.96 $37.06 $1.90
Sep-12 $36.89 $35.08 $1.81
Oct-12 $35.57 $33.97 $1.60
Average $37.24 $35.46 $1.78
(sorry for the lack of a screen snip, I'm new and the system won't let me post an image...)
I've created a tablix that does the monthly averages computation - I use a group in the table to group the 6 months of data by month (and then hide the hourly price data so you only see the month total row) but I'm stuck on how to calculate the bottom row of the table which is the average of each column. (the average of the averages is not the same as the average of all 6 months of prices from the underlying data - that's what I've learned in this process... IOW, that was my first solution :-) )
What I tried to do to get the average of the averages was give the month total cell a name, MonthlyAvgPrice1, then in the bottom row, used this expression:
Avg(reportitems!MonthlyAvgPrice1.Value)
As I kind of expected, this didn't work, when I try to run the report, it gets a build error saying "The Value expression for the textrun 'Price1PeriodAvg.Paragraphs[0].TextRuns[0]' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers."
Hopfully I've explained this well, does anyone know how to do this?
Thanks!
-JayG
Actually it is not clear from the question that how are you in particular binding the data to the report items, But from the given information what I understand is that you can
Try like this:
Right Click the tablix row and insert a row below
In the cell where you want to have this Average of Averages insert the following expression
=Sum(Fields!Price1.Value)/6
and similarly insert expression =Sum(Fields!Price2.Value)/6 and =Sum(Fields!Delta.Value)/6 in the other cells where you want to display the Averages
Of Course, you will change the Field names Price1,Price2 etc to the fields that you are getting the values from.
HTH

I am having problem to calculating % on base of subtotal value in Matrix in SSRS Report

I am having problem to calculate the % value on the base of subtotal per each row and in the column.
As you may see from the snap shot# 1, I am unable to calculate the percentage value basing upon the sub-total value (i.e. from the 1st row).
And this is how i want to show my output as shown below snapshot.
I found the answer for the above question calculating the percentage based on the subtotal for inscope values.
=FormatPercent(Sum(Fields!StartingInventory.Value)/Fields!Sum_StartingInventory.Value,1)