What does this formula mean in excel? (A cell equals a range) - excel

I see the following formula in a Excel spread sheet and can not understand... Can anyone explain what the test condition "N5=N4:N741" mean?
=MIN(IF(N5=N4:N741,K4:K741))
I made some experiments and still cannot get a clue...

I'm assuming this is an array formula.
What this does is takes the minimum of the range K4:K741 where the value in N4:N741 equals the value in N5.
Let's look at a smaller example. K4:N9 is shown below.
K L M N
----------
4 | 4 2
5 | 8 7
6 | 3 4
7 | 2 1
8 | 7 9
9 | 1 7
The expression N5=N4:N9 is true in row 5 and row 9 since both of those match N5 (value = 7), giving the array {False,True,False,False,False,True} Thus IF(N5=N4:N9,K4:K9) will return {False,8,False,False,False,1} since the True values are replaced by the corresponding row in column K. The MIN() function will then ignore the False parts and return the minimum of the corresponding values in column K (the value 1 since 1 < 8).

I believe it returns an array of true and false values. I also believe the true shows up for the 3 because it is the third item in the array. but that is a guess on my part.
{false, false, true, false,false}
If you change your 5 in E1 to a 1, it will return a true.
Research all of many things excel

Related

Logical Functions in Excel for aggregate data

In MS Excel, I am trying to write an aggregate function that counts the number of entries in a data table that meets a set of requirements.
I have tried using the AND(), OR() operators, but they only return a single value even when I input an array.
AND(1={1,1},1={1,1}) returns TRUE, instead of {TRUE, TRUE}
I have also tried using * as AND and + as OR, but for some reason this is what I get.
1={1;1}*1={1;1} returns {FALSE;FALSE} when I am expecting a {TRUE;TRUE}
However, when I put it all together, it works except when (TRUE + TRUE) * TRUE, it evaluates into FALSE instead of TRUE. These are the functions I am using below and their expected results. (header is row 0)
count - {sum(IF( (A1:A5=1 + B1:B5=1)*C1:C5=1 , 1, 0))} = 2
sum - {sum(IF( (A1:A5=1 + B1:B5=1)*C1:C5=1 , D1:D5, 0))} = 7
min - {min(IF( (A1:A5=1 + B1:B5=1)*C1:C5=1 , D1:D5, 9999999))} = 3
max - {max(IF( (A1:A5=1 + B1:B5=1)*C1:C5=1 , D1:D5, 0))} = 4
A B C D
1 1 1 3
1 0 1 4
0 0 0 5
0 0 1 6
1 1 0 7
If you array enter then it does return an array, but you need to array enter over many cells.
For example: Highlight a range 2 high and 2 wide. In the formula box put:
=(1={1,0})*(1={0;1})
and hit Ctrl-Shift-Enter. You will return an array of values:
By adding the SUM to the outside we are returning that array to the sum:
=SUM((1={1,0})*(1={0;1}))
Hit Ctrl-Shift-Enter and you will get the sum of the array or 1
If you want to display the array, one must array enter the formula over many cells, otherwise the display will only be the upper left value of the array.
If our data is like:
So we want to count rows where either A or B or both are 1 and C is a one.
(the 12 yellow rows)
We can use:
=SUMPRODUCT(--((A1:A28)+(B1:B28)<>0)*(C1:C28))

Subtract cells when the condition matches in a Row

How do I subtract horizontal multiple cells when the condition matches.
If match found then return subtracted value if not then return current value.
I tried the below formula but not able to do multiple matches
=IF(ROW(A3)=2,0,D3-D2)
Date Type Content Value Answer
1-Oct-18 Type 1 Content 1 7 7
1-Oct-18 Type 1 Content 1 7 0
1-Oct-18 Type 1 Content 1 9 2
2-Oct-18 Type 2 Content 1 8 8
2-Oct-18 Type 2 Content 2 10 10
2-Oct-18 Type 2 Content 2 3 -7
Put this in E2 and copy down:
=D2-SUMIFS($E$1:E1,$B$1:B1,B2,$C$1:C1,C2)
You do not need to check the row here as your current formula does. ROW(A3) will always return the row. Thus your test statement can be reduced to 3 = 2 which will always show TRUE
The equation you are looking for is =IF(A2=A1, D2-D1, 0)

Excel array query

I'm struggling to understand the mechanics of a particular array formula. I have a row of data ranging from January 2015 to December 2016. Let's assume the data is populated up to October 2016 and the sum in October is £1,000. When data is entered into November 2016 say £1,250, the formula below automatically calculates the delta between the two months. How did the formula do that. Could someone help provide a simple explanation of the below, in particular how it knew to deduct the latest month from the prior month.
=(INDEX(60:60,MAX(IF(M60:AV60<>"",COLUMN(M60:AV60)))))-(INDEX(60:60,MAX(IF(M60:AV60<>"",COLUMN(M60:AV60)-1))))
Thanks for your help,
Miles
It's a little complex, but let's break it down a piece at a time.
This looks to be an array formula, which means that rather than dealing with a single cell, it can deal with a whole set of cells at once.
M60:AV60<>"" This segment produces an array (list) of TRUE and FALSE values, looking at each cell between M60 and AV60. Wherever the cell contains a value - ie is not blank - it returns TRUE. Wherever the cell does not contain a value, it returns FALSE. This list exists only in the program's working memory, and it isn't recorded anywhere in the sheet. So we have something like this:
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
FALSE
FALSE
FALSE
FALSE
FALSE
COLUMN(M60:AV60) This segment produces another array, the same size as the TRUE/FALSE array above, that simply contains the column numbers of every cell from M60 to AV60. We now have two lists - one containing TRUE/FALSE, and one containing numbers, both the same length.
TRUE | 1
TRUE | 2
TRUE | 3
TRUE | 4
TRUE | 5
TRUE | 6
FALSE | 7
FALSE | 8
FALSE | 9
FALSE | 10
FALSE | 11
IF(M60:AV60<>"",COLUMN(M60:AV60)) This IF statement combines the TRUE/FALSE array with the column numbers array to get something more useful. Wherever there is a TRUE in the first array, it is replaced with the corresponding number from the second array; wherever there is a FALSE in the first array, nothing is changed, and the value stays at FALSE. This way, we end up with a list of numbers, representing the columns of each non-blank cell. It's the equivalent of running the IF formula on all the members of the array.
IF | TRUE |THEN| 1 = 1
IF | TRUE |THEN| 2 = 2
IF | TRUE |THEN| 3 = 3
IF | TRUE |THEN| 4 = 4
IF | TRUE |THEN| 5 = 5
IF | TRUE |THEN| 6 = 6
IF | FALSE |THEN| 7 = 0
IF | FALSE |THEN| 8 = 0
IF | FALSE |THEN| 9 = 0
IF | FALSE |THEN| 10 = 0
IF | FALSE |THEN| 11 = 0
The last column, after the =, is what is passed to the MAX function.
MAX(IF(M60:AV60<>"",COLUMN(M60:AV60))) This segment cuts down the list of numbers to just one number, the Max or highest number in the list. Thus we end up with a single result, which represents the last column that contains a value.
INDEX(60:60,MAX(IF(M60:AV60<>"",COLUMN(M60:AV60))))) The INDEX function looks at all of row 60, and returns a value from a specified column in that row. That being the column returned by the previous segments - the last column that contains a value.
The second half of the formula with the second INDEX function does exactly the same thing, but it subtracts 1 from the column number returned - that is, it gets the second-to-last column that has a value.
The end result is subtracting the second-to-last value from the last value, to get the difference between them.

How to get cells value from previous visible row in excel formulas

Is it possible to write a formulas in Excel,to calculate value based on the previous visible row?
By applying a Filter on the columns, the previous visible row changes but the usual formals does not consider visibility of the previous row, so the result does not change by applying filters. For example:
Let's original values of the spreadsheet cells be:
A | B | C | D
1: 5 3 1
2: 9 1 1
3: 2 3 0
4: 7 8 1 =A3-B4 equals 2-8=-6
Now assume that we make a filter on C column to hide the third row so we have
A | B | C | D
1: 5 3 1
2: 9 1 1
4: 7 8 1 =A3-B4 is still equals -6 but I want to get: 9-8=1
Is it possible to get such a formulas? Thank you very much.
Try this formula
=LOOKUP(2,1/SUBTOTAL(3,OFFSET(A$1,ROW(A$1:A3)-ROW(A$1),0)),A$1:A3)-B4
The SUBTOTAL/OFFSET part returns a 1 or zero for each value in column A depending on whether it's visible or not, LOOKUP finds the last 1 (equivalent to the last visible value) and gives that value.

Understanding excel formula

I have a excel formual. =IF(SUMIFS(G:G,D:D,D2)>0,"YES","NO")
I searched on net but found any suitable answer to understand this.
http://office.microsoft.com/en-in/excel-help/sumifs-function-HA010047504.aspx
http://www.myonlinetraininghub.com/excel-2007-sumif-and-sumifs-formulas-explained
I did not find any help from the above link. Could any one please help what this formula actully mean?
You first need to understand how the SUMIFS(G:G,D:D,D2) works. It returns the sum of rows within G:G where the corresponding D:D is equal to D2, as explained by the Microsoft link you have already. E.g.
| D G
--+-----------
1 | H1 H2
2 | A 1
3 | B 2
4 | C 3
5 | D 4
6 | A 5
7 | B 6
8 | C 7
9 | D 8
Here, D2 is A. SUMIFS(G:G,D:D,D2) will return the sum of values from G where the ones in D are equal to A, which is 1 + 5 = 6
So, if this sum is above 0 in
=IF(SUMIFS(G:G,D:D,D2)>0,"YES","NO")
Then, put YES, otherwise NO.
The SUMIFS function takes at least three arguments:
the range to be summed
the range to be tested
the condition that the second range is tested for (e.g. ">0")
In your example this function is evaluated; if the result is greater than zero, the outermost IF returns the string "YES", otherwise it returns "NO".
In other words - your expressions tells us whether (the sum of all elements in the first range for which the second range meets the condition in the third range), is greater than zero or not.

Resources