I am trying to isolate a sort by a number found at the end of a cell's value (i.e "APG-1710-082521-A4" and returning the value "4")
This is the formula that I am using:
=RIGHT(A2,LEN(A2)-SEARCH("$",SUBSTITUTE(A2,"A","$",LEN(A2)-LEN(SUBSTITUTE(A2,"A","")))))
This formula works for getting the number isolated in a new column, but when I sort that column, it only sorts by the first digit
Example:
1,
1,
1,
1,
12,
14,
15,
15,
15,
17,
2,
2,
2,
225,
What can I do to make sure that the whole number/cell value is being read?
The key to make your own formula work is given by #BigBen, but your formula is rather lenghty. Here is a formula that will extract the number from the right of your string:
=-LOOKUP(1,-RIGHT(A1,ROW($1:$99)))
If you must make this dynamic (length-wise) you can both try (depending on your version of Excel):
=-LOOKUP(1,-RIGHT(A1,ROW($A1:INDEX($A:$A,LEN(A1)))))
Or:
=-LOOKUP(1,-RIGHT(A1,SEQUENCE(LEN(A1))))
Related
I have a list of values between 1 and 100, essentially a sort of ranking that occassionally skips a few numbers (for example, the first ten values are 2, 6, 6, 10, 10, 10, 10, 11, 12, 13). They're ordered ascendingly, so every number will be either higher than or equal to the number above it. Now, I wish to remove all the duplicates from this list while remaining between 1 and 100. So, for example, for the values above, something like 2, 6, 7, 10, 11, 12, 13, 14, 15, 16 would work or 2, 6, 7, 8, 9, 10, 11, 12, 13, 14. However, the formulas I've tried so far will either go over 100, go under 1, or create circular references.
Given the nature of the list, there's very little chance of the amount of values exceeding 100, so if that possibility can be accounted for, it'd be a nice bonus, but it's not required.
Please create a named range for all your numbers and name it Source. As an alternative, replace the named range Source in my formulas below with the sheet address of the range where you have your numbers.
[C2] =INDEX(Source,MATCH(0,COUNTIF($C$1:$C1,Source),0))
This is an array formula and needs to be confirmed with Ctl + Shift + Enter. Observe that the COUNTIF range is defined one row above the row in which the formula resides. Its formulated with one absolute and one relative end. The end of the range will expand as you copy the formula down.
You can achieve a similar result using the LOOKUP() function. But since MATCH() finds the first instance, LOOKUP() returns the last. Therefore the formula below will return the same sequence in descending order. LOOKUP() is capable of looping on its own and the formula doesn't require array enabling. Just confirm it normally, with only Enter.
[E2] =LOOKUP(2,1/(COUNTIF($E$1:E1,Source)=0),Source)
Observe that the result range is defined with an absolute and relative end, starting above the row of the formula as explained above.
In B2, formula copied down :
=IF(A2="","",IF((COUNTIF(B$1:B1,A2)>0)+(A2=A1),B1+1,A2))
Edit #1
If data have repeated 100 as per OP's comment, then B2 formula become :
=IF((COUNTIF(B$1:B1,100)>0)+(A2=""),"",IF((COUNTIF(B$1:B1,A2)>0)+(A2=A1),B1+1,A2))
Thank you everyone for posting! Thanks to Bosco's original reply, I managed to fiddle around and find the answer myself. The biggest issue I was facing was getting a circular formula error, but by using Bosco's formula as a help column I was able to get it all worked out.
So, the solution holds 3 different columns: Original Data (column A), Help Column (column B) and Final Result (column C).
In the Help Column, I did as suggested, in cell B2 and copied down:
=IF(A2="","",IF((COUNTIF(B$1:B1,A2)>0)+(A2=A1),B1+1,A2))
This would occassionally create results over 100, so in the Final Column I placed the following array formula, which incidentally also accounts for lists longer than 100 entries, in C2 and copied down:
=IF(B2="","",IF(ROW(C2)>101,ROW(C2),IF(AND(B2>=100,B3=""),100,IF($B2:$B$1000>=C3,C3-1,B2))))
As an array formula, this needs to be entered using Ctrl+Shift+Enter.
Thank you very much to everyone who posted replies, I'm sorry for my lack of clarity!
I have this COUNTIF formula:
=COUNTIF(A1:A20,A1:A20&"")
When I highlighted the formula and hit F9, I got the following array:
{1;2;2;1;1;1;1;1;1;2;2;2;1;2;4;4;4;4;1;1}
The formula by itself gives 2. I wonder from where the 2 come.
GDPXT01
GDPXT02
GDPXT02
GDPXT03
GDPXT04
PXQZW01
PXQZW02
PXQZW03
PXQZW04
OCCMD2
OCCMD2
DSOMR1
ITY
DSOMR1
PXQZW05
PXQZW05
PXQZW05
PXQZW05
BKXMA01
BKXMA02
It is important to know what is data in A1:A20, but this is result of your function, it is array! For example, for this data-set below you will get same result.
1,
2,
2,
3,
4,
5,
6,
7,
8,
9,
9,
10,
11,
10,
12,
12,
12,
12,
13,
14
We don't have clear understanding about your question unless see your excel sheet.
So I made some points that will helps for your understanding about COUNTIF function. COUNTIF, is used to count cells that match criteria.
=COUNTIF (range, criteria)
range - The range of cells to count.
criteria - The criteria that controls which cells should be counted.
Some Important Notes:
COUNTIF is a function to count cells that meet a single criteria.
COUNTIF can be used to count cells with dates, numbers, and text that
match specific criteria. The COUNTIF function supports logical
operators (>,<,<>,=) and wildcards (*,?) for partial matching.
Some Examples:
=COUNTIF(D5:D12,">100")
=COUNTIF(B5:B12,"jim")
Hope this might helps :)
Because you are using COUNTIF wrong. As per the documentation:
COUNTIF(range, criteria)
range (required) - The group of cells you want to count
criteria (required) - A number, expression, cell reference, or text string that determines which cells will be counted.
This tells you that Criteria accepts only one value, and not a range/array.
If you use the "Evaluate Formula" tool, you will see that your criteria (A1:A20&"") matches the current row. On row 1, it is treated as A1&"". On row 2, it is treated as A2&"". On row 15, it is treated as A15&"". You can also put identical copies of your formula in every row, from 1 to 20, to see this.
As such - on rows 2, 3, 10, 11, 12, and 14 the result will be 2. On rows 1, 4, 5, 6, 7, 8, 9, 13, 19, and 20 the result will be 1. And, on rows 15, 16, 17, and 18, the result will be 4.
As a bonus, rows 21+ will give a result of 0
I have a table where I an looking at time between orders. it looks something like this;
weeks 1, 2, 3, 4, 5, 6, 7, 8, 9
orders 1, 2, 0, 0, 1, 2, 3, 4, 5
where zero is an order present for that week overwise the cell is 1 + the previous week number.
I need to find the column ref for the second instance of zero (to find out how long the first order has lasted)
I'm trying to use something like:
=SMALL(IF(A2:H2=0,COLUMN(A2:H2),""),2)
But all I get #Value! error.
When I evaluate the error it seems it doesn't like the "A2:H2=0" calculation in the IF. I checked I wasn't screwing up something simple in the insert function tool and on here it gives me the value I want but on the sheet just gives me the #value! error...
I tried this with index too but can't seem to get it to work.
Does anyone have any advice to where I'm going wrong?
Thanks for your help!
your formula is correct, but you should make it an array formula. Go into the cell where the formula is placed and hit CTRL+SHIFT+ENTER. your formula gets { } wrapped around itself and shows the desired result.
For example, My values are 5, 1, 6, 7, 8, 4, 7. I would like to find the last value that is less than each cell. The last value less than 5 would be 4. The last value less than 8 would be 7, etc. I'm currently using this formula:
=LOOKUP(9.999999999999E+307,IF(B2:$B$4204
But I'm having no luck. Thanks for your help.
This will return the last value in the list that is less than the value:
=INDEX(A:A,AGGREGATE(14,6,ROW($A$1:$A$7)/($A$1:$A$7<A1),1))
If you only want to look at the values under the current value change to:
=INDEX(A:A,AGGREGATE(14,6,ROW($A1:$A$7)/($A1:$A$7<A1),1))
I have a column array with the following values in my sheet: 11, 15, 5, 7, 2. I want to get a reference to the cell which contains the value 15. How would I go about doing this?
Thanks
If your array is A2:A13 here is a formula that will get you the reference to the cell with a value of 15...
INDEX(A2:A13, MATCH(15, A2:A13))