I am trying to lookup data that is the first occurrence of an ID looking upwards in excel. I would like to stop looking upwards when the cell value is ID is 0.
I have used the following to find the first occurrence when looking upwards:
In Cell D8:
=LOOKUP(2,1/($A$2:A8=C8),$B$2:B8)
In Cell D9:
=LOOKUP(2,1/($A$2:A9=C9),$B$2:B9)
For the case of desired outcome = 13 this works, however when there are consecutive IDs I would like to return the top most non-zero data field. Example desired outcome = 15 with the current formula returns 0.
How can I continue looking upwards until the top most ID = 2 before ID =0?
+----+------+--------------+-----------------+
| ID | Data | Lookup Value | Desired Outcome |
+----+------+--------------+-----------------+
| 2 | 18 | 1 | No Formula |
+----+------+--------------+-----------------+
| 1 | 25 | 2 | No Formula |
+----+------+--------------+-----------------+
| 0 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
| 1 | 13 | 0 | 0 |
+----+------+--------------+-----------------+
| 2 | 15 | 0 | 0 |
+----+------+--------------+-----------------+
| 2 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
| 2 | 0 | 1 | 13 |
+----+------+--------------+-----------------+
| 1 | 0 | 2 | 15 |
+----+------+--------------+-----------------+
| 0 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
| 0 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
Put this in D4 and copy down:
=IFERROR(LOOKUP(2,1/(($A$2:A4=C4)*($B$2:B4<>0)),$B$2:B4),0)
Put this in D4 and copy down:
=IFNA(LOOKUP(9^9,1/B$2:B4^-1/($A$2:A4=C4)),)
Related
| A | B |
---|--------|--------|---------
1 | 0 | 500 |
2 | 0 | |
3 | 0 | |
4 | 500 | |
5 | 400 | |
6 | 0 | |
7 | 700 | |
8 | 300 | |
9 | | |
In Cell B1 I want to display the first value that is <> 0 in the Column A.
(in this example it would be 500)
I tried to go with something like this but could not make it work:
B1 =LOOKUP(2,1/(A1:A8<>0),A1:A8)
How do I need to modify the formula to get the needed result?
Can try FILTER().
=#FILTER(A:A,A:A>0)
Index and Match will find the next non 0 in a column
=INDEX(A:A,MATCH(TRUE,INDEX(A:A<>0,),0))
I have in Row 4 across my columns a flag which is either 1 or 0.
Row 7 contains my dates across columns.
I am trying to do a dropdown validation for only the dates which have 1 as the flag in their column.
=OFFSET(LEDGER!$M$7,0,COUNTIF(LEDGER!$M$4:$CV$4,"=1"),0)
this doesn't seem to work. Is what I am looking do-able?
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | | |
|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|---|---|
| 31-Dec-10 | 31-Dec-11 | 31-Dec-12 | 31-Dec-13 | 31-Dec-14 | 31-Dec-15 | 31-Dec-16 | 31-Dec-17 | | |
If your dates starts from D7 and if the flags starts from D4 then try this formula.
=OFFSET($D$7,0,0,,COUNTIF($D$4:$K$4,"<>0"))
I'm a bit confused. I need to make an example of using the ITE-Algorithm on every Boolean operation. But I actually don't know how much there are?
As an example I mean, AND, OR, XOR, XNOR, NOR, NAND, NOT. And I don't know the other ones... I at least miss one because it cannot be seven operations. (2^n)
I need to make an example of using the ITE-Algorithm on every Boolean
operation.
This is Exercise 1 from the Fascicle 1B of the Volume 4 of Knuth's The art of computer programming.
The answer is the following.
But I actually don't know how much there are?
There are exactly 16 boolean functions of two variables (and 22ⁿ functions of n variables). Just permutate rows in functions' truth tables.
| F0 | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | FA | FB | FC | FD | FE | FH |
|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
F0 and FH do not depend on the values of both variables.
F3, F5, FA, FC depend on the value of only one variable.
The table below lists common names of these functions.
The above table is from the Fascicle 0B of the Volume 4.
I'd add that F8 and FE are also known as Pierce's arrow and Sheffer stroke respectively.
I have this data below in Excel. What I want is to return the No.of Inactive months and the Inactive months themselves.
ACTIVITY MONTH
Jan17 Feb17 Mar17 Apr17 Reg Month No.Inactive months Months Inactive
User ID
1 5 38 0 60 Jan17
2 0 242 203 20 Feb17
3 30 0 0 30 Jan17
4 0 0 0 40 Apr17
5 0 0 16 0 Mar17
To count the inactive months you can use the following.
+---+------+--------+--------+--------+--------+--+-----------------+
| | A | B | C | D | E | F| G |
+---+------+--------+--------+--------+--------+--+-----------------+
| 1 | User | Jan 17 | feb-17 | mar-17 | apr-17 | | Inactive months |
| 2 | 1 | 5 | 38 | 0 | 60 | | 1 |
| 3 | 2 | 0 | 242 | 203 | 20 | | 1 |
| 4 | 3 | 30 | 0 | 0 | 30 | | 2 |
| 5 | 4 | 0 | 0 | 0 | 40 | | 3 |
| 6 | 5 | 0 | 0 | 16 | 0 | | 3 |
+---+------+--------+--------+--------+--------+--+-----------------+
where in cell G2 the is this formula =COUNTIF(B2:E2,0)
To show the list of inactive months it's a little bit harder.
The point is that you have to explain how you want to see these results.
The easier way is to use the conditional formatting anc color the cell with zero (but this is not so useful). Others way could be to traspose the table and filter the column with zero. Another one could be to use a VBA macro....
I'm trying to get a cell with value BBBBBBBGGGGGJJJJCCCCDDDDAA from these cells:
-----------------------------------------
| 2 | 7 | 4 | 4 | 0 | 0 | 5 | 0 | 0 | 4 |
-----------------------------------------
So it gets the highest value and writes the cell's horizontal address (that might have an offset) that many times. Then gets the next highest and does the same thing until it reaches the zeroes. Is that possible in excel?
additional samples:
------------------------------------------------------------------------------------
| 2 | 0 | 0 | 3 | 0 | 0 | 5 | 0 | 0 | 0 | GGGGGDDDAA |
------------------------------------------------------------------------------------
| 0 | 0 | 2 | 0 | 0 | 0 | 5 | 0 | 0 | 0 | GGGGGCC |
------------------------------------------------------------------------------------
| 0 | 7 | 2 | 2 | 4 | 3 | 3 | 0 | 0 | 0 | BBBBBBBEEEEFFFGGGCCDD |
------------------------------------------------------------------------------------
| 4 | 7 | 0 | 7 | 7 | 0 | 0 | 0 | 8 | 7 | IIIIIIIIBBBBBBBDDDDDDDEEEEEEEJJJJJJJAAAA |
------------------------------------------------------------------------------------
| 0 | 2 | 0 | 2 | 8 | 0 | 8 | 0 | 7 | 10| JJJJJJJJJJEEEEEEEEGGGGGGGGIIIIIIIBBDD |
------------------------------------------------------------------------------------