Formula to calculate a sum of differences and count them - excel

I have the following Excel spreadsheet:
A B C D E F G H
1 Sales 500 700 600 450 550 600 500
2 Helper Row (Differences) 40% -14% -25% 22% 9% -17%
3 Helper Row (Counts) 0 0 1 0 0 0
4 Count Result 1
In Row 1 you can see the sales over different periods. In Row 2 the difference between the sales are displayed. (e.g. formula in C2=C1/B1-1).
In Row 3 the formula indicates 2-Following-Periods in which in total the sales drop by >-20%.
In the case above this applies to cell E3 because the sales in cell D2 drop by -14% and in the next period in cell E2 by -25% which makes a total drop of those two periods by -39%.
The formula I use in Row 3 is for example E3=IF(SUM(D2:E2)<-0.2,1,0).
Eventually, I use a sum function in cell B4 (B4=SUM(B3:H3)) to count how often the above described criteria is met.
All this works perfectly so far. However, my target now is to get rid of the Hepler Row 2 and Row 3.
Do you know a formula that gives me the count result which meets the above described criteria?

Assuming that your above demonstrated numbers are in cell B1:H1, you can use following formulae to achieve result without helper cells.
Array formula (CTRL+SHIFT+ENTER and not just ENTER)
=SUM((((C1:H1-B1:G1)/B1:G1)<-0.2)+0)
Or for normal ENTER
=SUMPRODUCT((((C1:H1-B1:G1)/B1:G1)<-0.2)+0)

Related

Check if there is at least one value in column C that is bigger then the value in Column B (without Helper Column)

A
B
C
D
1
Product
sales_volume
purchase_volume
Check
2
Product_A
500
400
yes
3
Product_B
600
700
4
Product_C
300
250
5
Product_D
800
620
6
Product_E
100
100
7
In Cell D2 I want to have a formula that is doing the following:
= If there is at least one value in Column C > value in Column B then "yes" else "no"
I know I could achieve this with a Helper Column that subtracts the values from both Columns and then check the Helper Column for values >= 0.
However, I would prefer a solution without a Helper Column.
Do you have any idea if this is possible?
=IF(SUM(IF(C2:C6>B2:B6, 1, 0))>0, "yes", "no")
Be warned this is an array formula so might required you to press Ctrl+Shift+Enter after typing the formula instead of just inserting it normally
If B2 is GREATER than the largest number in the range C2:C6, then "no", else "yes".
Try this formula in cell D2:
=IF(B2>MAX(C$2:C$6),"no","yes")
you can then drag the formula down to other cells

Calculate results and then count them based on a criteria in one formula

I have the following Excel spreadsheet:
A B C D E
1 Sales 500 200 400 300
2 Difference (Helper Row) -60% 100% -25%
3
4 Criteria: -20%
5 Result: 2
Formulas:
C2 = C1/B1-1
D2 = D1/C1-1
E2 = E1/D1-1
B5 = COUNTIF(B2:E2,"<"&-0.2)
In Row 1 you can see the sales over the last 4 periods. In Row 2 the difference between the sales is calculated using the simple formulas described above.
In Cell B5 I want to show the number of differences (Row 2) which are below the criteria in Cell B4. In this case the result is 2 because -60% and -25% are below the criteria of -20%.
All this works perfectly so far. However, I would prefer to have this system without the Helper Row 2 that I currently use to calculate the differences between the sales in Row 1.
Do you know a formula that gives me the exact same result but calculates the differences automatically and then counts them if they meet a certain criteria?
Try the following
=SUMPRODUCT(--(C1:E1/B1:D1-1 <B4))
If dealing with potential 0s in Sales
={SUM(--(IFERROR(C1:E1/B1:D1-1,0)<B4)*--(C1:E1>0))}

Use value in cell as index for row in Excel SUM function

Given the two worksheets below, I want to put a SUM in Column F for each row but instead of SUMMING the values in Sheet1, I need to use the cell value in Sheet1 as the row number in Sheet2 and use those cell values in the SUM. For example, the SUM for Bill should be SUM(Sheet2! B1,C6,D4,E3) = 200.
Sheet1
A B C D E F
Bill 1 6 4 3 200
Sue 2 1 3 2 450
Mary 3 2 2 1 550
Joe 4 3 1 4 150
Alice 5 4 25
Bob 6 5 0
Sheet2
A B C D E
1 100 200 50 400
2 50 100 25 200
3 25 50 0 100
4 0 25 0 50
5 0 0 0 0
6 0 0 0 0
This is just a sample spreadsheet; in the real one there are already 40 columns with more being added as necessary.
In Sheet1!F1:
=SUMPRODUCT(N(OFFSET(Sheet2!$A$1,B1:E1-1+(B1:E1-1<0)*(2^20-1),COLUMN(B1:E1)-1)))
Copy downwards as necessary.
The cells Sheet2!1048576:1048576 should not have content. Because those cells will be referenced if the row number given in Sheet1 is 0 or empty.
With the data to be summed in Sheet2!A1:E6, use this formula in Sheet1's first row's column F.
=SUM(INDEX(Sheet2!B:B, B2)*SIGN(B2), INDEX(Sheet2!C:C, C2)*SIGN(C2), INDEX(Sheet2!D:D, D2)*SIGN(D2), INDEX(Sheet2!E:E, E2)*SIGN(E2))
A zero or blank in Sheet1 would mean the entire column but that is multiplied by the SIGN function of that cell's value. Anything multiplied by zero equals zero and that will not impact the overall sum.
      
Using the INDEX function with the cell's value supplying the row_num parameter allows you to avoid volatile¹ functions that would negatively impact the calculation lag of the workbook.
¹ Volatile functions recalculate whenever anything in the entire workbook changes, not just when something that affects their outcome changes.

Issues with VLOOKUP in Excel

I have a tax table in one sheet that has a list of tax values. For example:
Sheet1: Tax Tables
A B C
1 Min Max Taxed
-------------------
2 50 100 10
3 100 200 20
4 200 300 30
In another sheet I have a gross income value of say 120 in cell A1. What I want to do is have a vlookup (I'm assuming that's what I should use) that checks cell A1 to see if it's between the Min and Max and then outputs the taxed amount in B1.
Sheet2: Income
A B
1 Gross FedTax
-----------
2 120 Value from Column C goes here
I already have the sheet in Tax Tables set up with named spaces A:C=Min and B:C=Max
I tried doing this:
=AND(VLOOKUP(<A1,Min,3,False),VLOOKUP(>A1,Max,2,FALSE))
But not even close...
I just want to check column A in the first sheet to see if it's less than the the value in the second sheet, and check column B in the first sheet against the value in the second for if its more, then put the value in column C in the first sheet into the cell next to the value in the second sheet.
To use a VLOOKUP, put your maximums and minimums in the same column.
Then use the TRUE argument, which means it looks for the next value that matches. Assuming the value you're looking up in D2, you'd put a formula like this in E2:
=VLOOKUP(D2,$A$2:$B$5,2,TRUE)
First of all it is unclear what you would apply when the amount is exactly 50/100/200/300/... So i decided to include the lower limit in the interval and exclude the upper limit.
For this problem I would use a sumifs like this (you have to decide on which side to put the equal sign:
=SUMIFS(Sheet1!C:C;Sheet1!A:A;"<="&A1;Sheet1!B:B;">"&A1)
This would only take those elements in column C that have a value in column A smaller than or equal to 120 and a value in column B greater than 120

Find value in 2D array and return value in adjacent cell

**Sheet 1**
ColumnA B C D E F G H
------------------------------------------------------------
EURUSD 1.2765 1 ACCOUNT624 2 account125 1 account834
EURCAD 1.01 2 Account49 3 account45 2 account67
EURGBP 0.78 2 Account777 1 account45 2 account678
**Sheet 2**
ColumnA B C D
---------------------------------------
EURUSD 1.2765 Account 624 ?
EURUSD 1.2765 Account 125
EURUSD 1.2765 Account 834
EURCAD 1.01 Account49
EURCAD 1.01 Account45
In Sheet 1 above each row shows a currency trade and what quantity goes to each account.In Sheet 2 each row shows 1 account only. I would like to populate columnd D in sheet 2 with the quantites from sheet 1.
Breaking it up into steps, i would like to:
Find the price in Sheet2!B1 in sheet1
On the same row in sheet1, find the cell containing the same account as Sheet2!C1
Return value in cell to the left of cell with matching account
I have used index/match before but I can't get it to work for 2 dimensional arrays. Can anyone help with a formula? Thanks in advance!
It's not pretty, but using what you requested - to find the match based upon price in column B (I would say your safer bet would be to use the Currency conversion "EURUSD", for example, since what if 2 currencies have the same ocnversion rate??), paste this formula in cell D1 on your second sheet:
=OFFSET(Sheet1!$B$1,MATCH(B1,Sheet1!$B$1:$B$3,0)-1,MATCH(C1,OFFSET(Sheet1!$B$1,MATCH(B1,Sheet1!$B$1:$B$3,0)-1,0,1,10),0))
You can then drag it down / change ranges as needed.
(PS - I'm also assuming you made a mistake on sheet2 and that the account numbers will be typed the exact same in both sheets)

Resources