Flag rows contributing to the sum criteria - excel

I have two columns like this:
Name Value
A 1
A 4
B 3
B 2
B 5
C 6
C 8
C 10
C 4
I am doing sumif based on Names but I have a criteria to full fill. Looking from the least values in a name group whenever my sum reaches lets say 5 I want those rows to have a flag 1 or else 0. In this example it should be:
Name Value Flag
A 1 1
A 4 1
B 3 1
B 2 1
B 5 0
C 6 0
C 8 0
C 10 0
C 4 1
The data is random and not in any order and file is dynamic so can not work around by just putting it in decreasing order. I do not have any idea about offset. Could it be done without using offset and only by regular ifs, sumifs etc. Thanks a tonn!

Perhaps this can be simplified somewhat, though, assuming you put your chosen threshold (e.g. 5) in J1 and that, as implied by your reply to my last comment, no one value for a given Name occurs more than once, then, in C2, array formula**:
=IFERROR(GESTEP(MATCH(1,0/(MMULT(0+(ROW(INDEX(A:A,1):INDEX(A:A,COUNTIF(A$2:A$10,A2)))>=TRANSPOSE(ROW(INDEX(A:A,1):INDEX(A:A,COUNTIF(A$2:A$10,A2))))),SMALL(IF(A$2:A$10=A2,B$2:B$10),ROW(INDEX(A:A,1):INDEX(A:A,COUNTIF(A$2:A$10,A2)))))<=J$1)),MATCH(B2,SMALL(IF(A$2:A$10=A2,B$2:B$10),ROW(INDEX(A:A,1):INDEX(A:A,COUNTIF(A$2:A$10,A2)))))),0)
Copy down as required.
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

In column C add
=IF($B10<5,1,0)
Im assuming the last value is meant to be 0 as the values in C have already passed 5? Try this one.
=IF(SUM(A2:INDEX($B$2:$B$10,MATCH(A2,$A$2:$A$10,0)))<6,1,0)

Related

Populating Excel table using 2 cell coordinates - lots of data

I need your help with this problem I'm facing using Excel. Basically I need to populate a table, or better, a given group of cells (dimensions 3x3), and my starting point is:
row numb. column name. value
2 A 10
3 C 4
4 B 20
so I would need to obtain a group of cell like this:
1 A B C
2 10 0 0
3 0 0 4
4 0 20 0
where the cells that have no value can be 0 or whatever. In other words, I have the coordinates where I need to insert the value, and I need to be insert the value corresponding to the coordinates in the right cell.
I already tried many times using functions like MATCH, VLOOKUP and INDEX (also ROW and COLUMN) but without success, because it inserts the correct values but also other combinations of coordinates that I don't want.
My idea was to start from cell A2 and, with the formula, check if there's a match with the coordinates of row and column in the data, and finally print the value.
PS: I would prefer to avoid VBA.
Try this array formula: (Of course, change your cell ranges as necessary)
= IFERROR(INDEX($G$2:$G$4,MATCH(TRUE,ADDRESS(ROW(),COLUMN(),4)=($F$2:$F$4&$E$2:$E$4),0)),0)
Note this is an array formula, so you must press Ctrl+Shift+Enter rather than just Enter after typing the formula.
See working example below.

Generate Column of raw data based on frequency table in Excel

I have a column of numbers and a second column of numbers. The second column of numbers contains the frequency of the numbers in the left column.
I want to create a third column of numbers that has the raw data.
Example:
A B
1 5
3 2
4 4
Column C would look like:
C
1
1
1
1
1
3
3
4
4
4
4
How can I do that in Excel? Thanks!
Based on data in A1:B3, in C1, array formula**:
=IF(ROWS(A$1:A1)>SUM(B$1:B$3),"",INDEX(A$1:A$3,MATCH(TRUE,MMULT(0+(ROW(A$1:A$3)>=TRANSPOSE(ROW(A$1:A$3))),B$1:B$3)>=ROWS(A$1:A1),0)))
and copied down until you start to get blanks for the results.
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

A function or VBA code to determine the last digit in a number

In Excel 2016 I have multiple rows containing numbers no greater than 3 characters listed in column A. I am trying assign a group number based on the right most character in each row that are in column A. Once the number is determined the result is placed in column B of the corresponding row.
Example:
If rightmost character of the number is: a 1 or 6 in cell A1, then in column B1 it's given a 1.
If A1 is a 2 or 7 then B1 is 2.
If A1 is a 3 or 8 then B1 is 3.
If A1 is a 4 or 9 then B1 is 4.
If A1 is a 0 or 5 then B1 is 5.
Any suggestions on how to perform with a function or VBA code are appreciated.
Following your problem statment exactly: in B1 you can enter the formula:
=IF(MOD(MOD(A1,10),5)=0,5,MOD(MOD(A1,10),5))
And copy it down as needed.
The part MOD(A1,10) pulls off the last digit. You seem to want the remainder of this mod 5 -- hence the outer MOD in (MOD(MOD(A1,10),5). But -- if the mod is 0 you want to report it as 5 -- hence the overall IF
However -- an even quicker way is just:
=IF(MOD(A1,5)=0,5,MOD(A1,5))
Since literally pulling off the first digit is superfluous since 5 is a divisor of 10.
Finally, #chrisneilsen gave an elegant formula which is even shorter:
=MOD(A1-1,5)+1
For all remainders other than 0 , the -1 inside the MOD and the +1 outside cancel each other, but for multiples of 5 (remainder 0) the -1 inside the MOD converts the number to one with a remainder of 4, with 4 + 1 = 5 the final answer.

Way to count last values before each zero?

I am trying to count the last value before it resets back to zero multiple times per column. Here is my example
1
2
3
4
5
6
7
8
0
1
2
3
4
5
6
0
1
0
0
1
2
3
0
And the list goes on but for this example I would be looking to do something like a LARGE or SMALL where I could get the answers like this:
8
6
1
3
Ultimately I would like them to be in the descending order, but if that isn't part of the formula I can take care of that if I can just figure out a way to capture them.
Can this be done?
You can try the following in column B try the following =IF(A2=0,IF(A1=0,"";A1),"")
then filter column B on non blank value
Put your original data in column B
In cell A2 enter:
=IF(AND(B2<>0, B3=0),MAX($A$1:A1)+1,"")
and copy down. Finally in C1 enter:
=VLOOKUP(ROW(),$A$1:$B$23,2,FALSE)
and copy down till you see errors. Should look like:
Basically column A is a "helper" column used to mark all the "good" values to facilitate easy pick-up

EXCEL match 2 columns against each other

I have two columns of data, they look something like this:
A B C D
1 2 SOME RECORD
2 6 SOME RECORD
3 10 SOME RECORD
4
5
6
7
8
9
10
So basically column A is a list of indices, where some of them appear in column C with corresponding records saved in column D. Column B is currently empty, and what I want to do is if say index 2 appears in both column A and column C (they matches), then put the record beside C2 in the cell B2. So essentially I want it to look like this:
A B C D
1 2 SOME RECORD
2 SOME RECORD 6 SOME RECORD
3 10 SOME RECORD
4
5
6 SOME RECORD
7
8
9
10 SOME RECORD
Can someone help please?!! Thanks!!!
UPDATE: I tried this and it doesn't work. The data in column D is calculated using a UDF and is refreshing every 1 second. The VLOOKUP function fails even though I can see the 2 indices are the same!! Is it because of the format of the cell or column? I.e. does vlookup compare data type as well?
Assuming your data in A starts from A1 - put in B1 the following and autofill:
=IFERROR(VLOOKUP($A1,$C:$D,2,0),"")
This includes handling of missing values.
You'll want this:
B1=VLOOKUP(A1, C:D, 2, FALSE)
This will look up the value in column A within the array spanning columns C and D. It will give you the value found in the second column (D). FALSE makes it an exact match, otherwise you might get 2 and 20 matching because hey, they're kind of similar...

Resources