Calculated field totals not correct in PowerPivot - excel

I have a basic data set with a ton of slicers that roughly looks like this:
Hours SpreadPerHr Spread
5.00 5.00 25.00
10.00 2.00 20.00
8.00 10.00 80.00
Where Spread is a calculated value where Spread = Hours*SpreadPerHour. The problem is, the totals for these columns follow this formula too, so it looks like this:
Hours SpreadPerHr Spread
5.00 5.00 25.00
10.00 2.00 20.00
8.00 10.00 80.00
Total: 23.00 17.00 391.00
And while the hours total up just fine, SpreadPerHour is dynamic and so Spread is as well. It is incorrect to say Total Spread = Total Hours * Total SpreadPerHour. Totals should be:
Total: 23.00 17.00 125.00
Is there a way I can make excel leave totals for Hours as-is, but sum the column for Spread instead of multiplying totals?

Here is what I think you have in your Power Pivot Model:
You have a calculated measure for Spread, which I have labeled SpreadCalc1. The problem with this is that it does the aggregation before it does the multiplication. You need this operation to be done on a row-by-row basis and then aggregated. So instead of a calculated measure, you need to create a calculated column and then sum that column.
The column I have labeled as SpreadCalc has the formula =[Hours] * [SpreadPerHr].
The calculated measure I called Spread is just Sum([SpreadCalc]). You can see there that the total is 125 as desired instead of 391.

I know this might be a bit redundant now, but I would suggest a slightly different approach.
Adding calculated columns in "small" tables is fine, but it can cause serious performance issues with large databases.
So to solve your problem, I believe the "correct" way is to use SUMX function.
It calculates the expression specifically for each row, which is exactly what you need. And it is smart as far as performance goes (no need to add calculated columns or perform any source-data manipulations).
If you use this formula (correct the name of the table / measures), you should get the desired results:
SUMX(YourTable, [Sum Hour] * [Sum SpreadPerHr])

Related

Excel,Pivot table, subtract instead of using "difference from"

I have a pivot table (in Excel 2010), looking like something like this (Countries in columns, sellers(included Factory) in rows and sum of totals in values :
**Country** **Factory ** **Seller A** **Seller B** **Seller C**
USA 30 31 19
GB 12 10
Denmark 14 16 20
What I need is to find a price difference between factory and store prices. I have tried "difference from" calculation with supplier name as a base field and Factory as a base item, but that is not what I really want. I.e it gives Seller A -Factory, but I would like to have Factory-Seller A, so the negative value would mean that buying from seller would mean, that I lose money, if I go buy from the Seller A. Additionally, I would like to have blanks (not difference) in the cases where the seller does not sell the item (where there is a blank in the data).
I.e the output would be
**Country** **Factory ** **Seller A** **Seller B** **Seller C**
USA 0 -1 11
GB 0 2
Denmark 0 -2 -6
It seems so easy, but I could not figure out how to write it as my own calculated field (or item? -however I can't add an item, get an error).
Can it even be done? I would think so as the "difference from" seems essentially the same thing, but as I don't know how that looks as a field formula, I can't replicate it. Hope its not too messy question, but I have tried to figure it out whole day. Maybe I am simply bad at googling things.

How to work out the stamp duty rate for each band using excel?

I am trying to work out how to calculate stamp duty at each rate band using excel and struggling to do so, whatever I try is to no avail.
I have managed to calculate stamp duty of the overall price using the SUMPRODUCT formula but what I am really looking to do is calculate it at each band. For instance. If a house costs £300,000, what I want to know is how much it costs at each rate as described here https://www.gov.uk/stamp-duty-land-tax/residential-property-rates
Sorry if I did not explain myself clearly, I could not copy the different rates here as it got messed up.
I hope someone can help, I have been working on this for quite some time now, I understand there are calculators available online but I want to be able to do it in excel.
Here's what I came up with. In columns C and D, fill down the formulas to row 8, and given the property value in C1, the result will be given in D10.
A B C D
1 Value 1825000
2
3 Band Cutoff Value exceeding cutoff Duty paid in band
4 0% 125000 =MIN(C$1, B4) =MAX(A4*C4, 0)
5 2% 250000 =MIN(C$1-B4, B5-B4)
6 5% 925000
7 10% 1500000
8 12% 9999999999
9
10 Total duty paid =SUM(D5:D8)

excel if statement having a range in a single cell

At the moment I am working on using on implementing nested if statement in excel for a project. It involves calculating the tax of employees using a tax table and would like to know if it possible for a logical test to distinguish a range within a singular cell i.e $0-$18,000
If you are open to using VLOOKUP, you can create a table showing the range and the associated value with it and use vlookup with the last argument being TRUE (approximate match) to get the value.
This is the output:
1.00 10%
100,000.00 30%
40,000.00 25%
17,999.00 10%
18,000.00 10%
18,001.00 15%
Try nested IF and AND formulas in combination. For example, there are three ranges: 0-18 000, 18 000- 23 000, 23 000<, then use this:
=IF(AND(A1>=0, A1<=18000),"range 1",IF(AND(A1>18000, A1<=23000),"range 2","range 3"))

Calculating my tax automatically in Excel

It's my very first post here so hi all.
I did a lot of research before hand but couldn't find the answer I was looking for.
I want a spreadsheet in Google Sheets to automatically calculate my tax.
€0 - €11000 w/ 0%
€11000 - €18000 w/ 25%
€18000 - €31000 w/ 35%
€31000 - €60000 w/ 42%
€60000 - €90000 w/ 48%
€90000 - €1000000 w/ 50%
€1000000+ w/ 55%
So the first 11k are taxed with 0% the next 7k are taxed with 25% etc.
What I've had the following thought - give that F9 are my before tax earnings:
=IF(0<=F9<=11000,SUM(F9*0%),(IF(11000<F9<=18000,SUM((F9-11000)*25%),(IF(18000<F9<=31000,SUM((7000*25%)+((F9-18000)*35%),SUM(F9))))))
Unfortunately it just won't work.
Am I using the right function?
Is there anything out there which would make it much easier?
Thank you for your help.
Here is an example (Excel) for your problem:
In Cell A1 is your Money, paste the code in A2 for example:
=WENN(A1>10000;"10%";WENN(A1>7000;"7%";WENN(A1>5000;"5%";WENN(A1>3000;"3%";"0%"))))
FK
Excel does not work that way X<y<z. Plus it resolves in order so it is not necessary:
=IF(F9<=11000,SUM(F9*0%),(IF(F9<=18000,SUM((F9-11000)*25%),(IF(F9<=31000,SUM((7000*25%)+((F9-18000)*35%),SUM(F9))))))
if it is less than 11000 then the first will fire and none others. then if greater than 11000 but less than 18000 the second will fire, and so on.
List values of each bracket range with the percentage applied if it is above that amount, for example:
A B
1 11000 0.25
2 18000 0.35
3 31000 0.42
4 60000 0.48
5 90000 0.50
6 1000000 0.55
You can format the percentage values as percentages if you prefer. What is important is that the value is a decimal and not a string.
Then you can use the MATCH function to determine the row of the first value that is larger than your income. So if the cell holding your income is F9, you'd have:
=MATCH(F9;A1:A6;1)
But this only returns the row number. If we want to retrieve the tax applied, we'll need to use this to pinpoint the value in column B pertaining to that. To get a value pertaining at a certain point dynamically, we use INDEX.
So putting it together, you'd have:
=INDEX(B1:B6; MATCH(F9; A1:A6; 1); 1)
One minus this times the value in F9 to get the amount after taxes:
=F9*(1 - INDEX(B1:B6; MATCH(F9; A1:A6; 1); 1))
Why would you do it this way? It lets you change the values in an intuitive fashion without having to parse a long and arduous formula. You can also add new values with relative ease. Just remember to adjust the A1:A6 and B1:B6 ranges.
Good luck! Let me know how it turns out!
You might want to try this:
=if(F9<=0,"Error",IF(F9<=11000,0,(IF(F9<=18000,(F9-11000)*25%,(IF(F9<=31000,1750+(F9-18000)*35%,IF(F9<=60000,6300+(F9-31000)*0.42,if(F9<=90000,18480+(F9-60000)*0.48,IF(F9<=1000000,32880+(F9-90000)*0.5,487880+(F9-1000000)*0.55)))))))))

Analyzing how noisy a data set using Excel

I have a set of data that has over 15,000 records in Excel that is from a measurement tool that finds trends over a large areas. I'm not interested in looking for trends within the data as whole but rather over the data closest to each other to get a sense of how noisy (variation with neighboring records). Almost like I want to know the average standard deviation of looking at the 15,000 or so records only at 20 records at a time. The hope is the data values trend gradually rather than sudden changes from record to record and thus looks noisy. If I add a Chart and use the "Moving Average" Trendline it kind of visually shows how noisy the data looks across the 15,000 + records. However, I was hoping to get a numeric value to rate how noisy the data is vs. other datasets. Any ideas on what I could do here with formula's built-in Excel or by adding some add-in? Let me know if I need to explain this any better.
Could you calculate your moving average for your 20 sample window, then use the difference between each point and the expected value to calculate a variance?
Hard to do tables here, but here is a sample of what I mean
Actual Measured Expected Variance
5 5.44 4.49 0.91
6 4.34 5.84 2.26
7 8.45 7.07 1.90
8 6.18 7.84 2.75
9 8.89 9.10 0.04
10 11.98 10.01 3.89
The "measured" values were determined as
measured = actual + (rand() - 0.5) * 4
The "expected" values were calculated from a moving average (the table was pulled from the middle of the data set).
The variance is simply the square of expected minus measured.
Then you could calculate an average variance as a summary statistic.
Moving average is the correct, but you need a critical element - order. Do you date/time variable or a sequence number?
Use the OFFSET function to setup your window. If you want 20, your formula will look something like AVERAGE(OFFSET(C15,-10,0,21)). This is your moving average.
Relate that to C15, whether additive or multiplicative, you'll have your distance. All we need now is your tolerance.

Resources