I need to do a match/index search in reverse right to left
each cell with have an x i need do go from right to left find what column the x is in and report the position so can then go to the top of that column and pull that data. I basically need to find out what column is the last X in.
A B C D E F G H I J
State 27-Aug 28-Aug 29-Aug 30-Aug 31-Aug 1-Sep 2-Sep 3-Sep 4-Sep
VI X X X X X X
in above example 3 rows 10 columns if i want to see that the last X is in Column G(7) then i use the index to go to that column(7), row A to 1-sep as the answer.
This will find the last cell with a value, regardless of value:
=INDEX($A$1:$J$1,MATCH("zzz",A2:J2))
If you want to find the last X, regardless of what is or is not in any of the other cells, then use this formula:
=INDEX($A$1:$J$1,AGGREGATE(14,6,COLUMN(A2:J2)/(A2:J2="X"),1))
One note: this is an array type formula and will be slower than the prior formula. If you only have one it will not make a difference. If you have hundreds you will see a difference.
But if you have other text strings after the X and you want the X then it is the way to go.
try out
=INDEX(1:1,1,COUNTIF(2:2,"X")-1)
Assuming there are no gaps within the stream of X's
=MATCH(2,IF(A2:J2="x",1,FALSE))
This is an array formula.
This will give you last position of x. Then, like you indicated, put the result inside INDEX function and you should be good. I like this option because i can put any condition inside the if statement, like >0.
Related
I want to count occurrences of a value X within a range (B1:H38) only if the column A value in that row is value Y.
I got close with the following, but it gives a #VALUE! Error and I don’t think it’s the right fit for what I need:
=COUNTIFS(A1:A38,“Y”,B1:H38,”X”)
What is the correct way to do this?
Edit 1:
Column A is either blank, or one of 5 words.
Columns B through H are either blank, words, or numbers.
In my mind, the logic is: find items in A that match “Y”, then check the rest of the row from B to H for “X”.
There may be 0, 1, or up to 7 matches in a given row.
u already done it right.. it just that you formula is for 1 (one) time count.. not repeated # every row .
=COUNTIFS(A1,“Y”,B1:H1,”X”)
put that in C1, then draq downwards. That should do.
Please share if it works/not/understandable. ( :
I have a series of data. That goes down the left side column of dates...
8/2, 8/3, and such. Then 2 columns over I have a column left for if the date is checks so 8/2:X, 8/3:X, 8/4: ,8/5: and such. I'm wanting to reference the date in the last field that has a X in it
A B C D
8/1 X
8/2 X
8/3 x
8/4
8/5
Trying to reference the date for the last A cell if there is an X in the D cell. So it would be for 8/3 would be the date. I'm not sure how to run with this.
I've looked through but now sure how to state an if statement
To return the date in column A that is in the same row as the last "X" (or "x") in column D:
=LOOKUP(2,1/(D:D="X"),A:A)
If you only want you cells to calculate if there's an X in column E you could write it like this:
=if(E3="x","", [put your calculation here] )
If you only care if there's anything there, not necessarily an "x" or if you're worried about case sensitivity:
=if(isblank(E3),"", [put your calculation here] )
Then just drag this formula down.
Based on what you had told me use the following formula in cell H1:
=maxifs($A$3:$A$24,$E$3:$E$24,"x")
If I understood correctly, you want to return the highest date with a X in it right? You can simulate a MAX IF with array formulas:
{=MAX(IF(E:E="X",A:A,FALSE))}
(You have to enter the formula with CTRL + SHIFT + ENTER to get those brackets and to it work properly)
The IF part inside that formula returns only a list of values (inside the TRUE part) that the condition returns true
Edit: If you're using Excel 2013 and above, you should check #Mark answer, as it is a cleaner way to do it
Just going to throw my hat in the ring here for a formula that will display the value of date that corresponds to the largest row number with an X in it in column D.
AGGREGATE will find the row number as follows:
=AGGREGATE(14,6,ROW(D:D)/(D:D="x"),1)
That can be nested inside an INDEX function to return the cell address of corresponding date which in turns display the value of the cell as follows:
=INDEX(A:A,AGGREGATE(14,6,ROW(D:D)/(D:D="x"),1))
While the above does work, AGGREGATE is performing array operations. Therefore full column references like D:D should be avoided and reduced to a smaller range that would closer match your data in order to avoid excess calculations on blank cells.
If you can ONLY enter the X consecutively without skipping a date, for instance you would not mark 8/6 X if 8/5 has no X marked, then you can find the last date using the following formula:
=INDEX(Column_Date,COUNTIF(Column_X,"X"))
The look up is case insensitive which means you can also enter lowercase x instead of uppercase X in column D or mix them up, the formula will return the same result anyway.
The solution is using COUNTIF function to locate the position of the last X in Column E of your worksheet, and then use INDEX function to return the corresponding date in Column A.
COUNTIF is a combination of COUNT and IF function. I guess this might be the "IF" function you are after.
Please note if the X is not marked consecutively day by day, you may need to use someone else' answer.
Cheers :)
I am trying to exclude text from arrays in a SUMPRODUCT function.
The formula I am using is:
=SUMPRODUCT(--ISNUMBER(FIND("S",Schedule!$AT$14:$DP$100)),(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP")*((Schedule!$AT$14:$DP$100)))
Schedule!$AT$14:$DP$100: contains numbers and S (or s)
Schedule!$AT12:DP12: contains dates
D29 contains a date
Schedule!AT12:DP12: contains dates
E29 contains a date
Schedule!$A14:A100: contains various text of which I only want lines with VP in them included.
If I change Schedule!$AT$14:$DP$100 to Schedule!$AT$14:$DO$100 then it works, so I know if is the S in the cell that creates the error. I know I can't multiply an number by an S.
I also tried:
=SUMPRODUCT(--SUBSTITUTE(Schedule!$AT$14:$DP$100,"S",0),(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP")*((Schedule!$AT$14:$DP$100)))
I also tried, but to no avail.
=SUMPRODUCT(SUBSTITUTE(Schedule!$AT$14:$DP$100,"S",0)*(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP")*((Schedule!$AT$14:$DP$100)))
=SUMPRODUCT(SUBSTITUTE(Schedule!$AT$14:$DP$100,"S",0)*(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP"))
Basically what I am trying to say is:
If the cell is in a date range and has VP in the line then add up the cells in the range AT14:DP100 on the Schedule Sheet. So it will be the sum of [number x 1(true) x 1(true) x 1(true)] + [number x 0(false) x 1(true) x 1(true)]...
Where am I going wrong? I feel I may need to use an array formula (CTRL SHIFT and ENTER)
Due to the number of functions that won't automatically operate as Arrays in a SUMPRODUCT, you probably need to use an Array Formula. (i.e. use Ctrl + Shift + Enter)
Fortunately, you're already done all the heavy lifting involved. All we're going to do is re-write your current SUMPRODUCT(<Condition>,<Values>) as {SUM(IF(<Condition>,<Values>,0))}:
{=SUM(IF(ISNUMBER(FIND("S",Schedule!$AT$14:$DP$100)),(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP")*((Schedule!$AT$14:$DP$100)),0))}
I have multiple columns as follows
A B C D Outcome
Y Y
N N
N N
Y Y
My outcome is in the column E. If the cell is filled, I want to see it in the outcome column. If not I want to see a blank cell. I tried my best, but I could do it. Is there a simple function to do it. Thanks for your help.
There are a number of ways to accomplish this. One would be:
// Copy this down
In Cell E2: =IF(COUNTA(A2:D2)=0,"",CONCATENATE(A2,B2,C2,D2))
Try :
=A2&B2&C2&D2
I'm trying to write an If or SumIf to calculate(sum) totals for x , y and z individually.
I could use a simple sum formula but these are thousands of columns and x and y and z are populated randomly. I tried using a range by sorting colA but its a temporary solution and not what I am looking for.
I need something like:
If COL A has 'X' then add values corresponding to X in COL B
example:
COLA COLB ....... colx
x 1
x 2
x 1
y 3
x 3
z 3
x 4
I tried looking up other answers for similar questions but could not find the right one that works for me.
If you want to sum multiple columns based on a value in a single column you could use SUMPRODUCT like this
=SUMPRODUCT((A2:A100="x")*B2:X100)
There can't be text in the sum range, B2:X100, otherwise you get an error - if you want to allow text in that range use this version:
=SUMPRODUCT((A2:A100="x")*ISNUMBER(B2:X100),B2:X100)
Maybe (difficult to tell from the question):
=sumif(A:A,"=x",B:B)
Another answer could be that you create a pivot table of the database. Insert>Pivot Table>Select your table range. Then from there, you would put the column heading you wanted sorted into the row criteria, and then sum the x1's and y'1s.
I am assuming you want to obtain subtotals for each column and each letter, as in the figure below.
If so, enter in B12 the formula
=SUMPRODUCT(($A$2:$A$8=$A12)*(B$2:B$8))
Copy and paste into B12:C14. It is easy to adapt to slightly different arrangements.
I apologize if my question was vague. This is my first time working with if and sumif formulas in Excel.
This is what I was looking for: =sumif(A:A,"=x",B:B).
Thank you Pnuts.