I'm looking for a way or ideas (preferable array solution), where you can determine if the numbers in a row increases.
The excel formula should give me "True" for the following sequence, since I want it to exclude #N/A values.
Example:
0,22 0,275 0,3162 0,36 #N/A 0,46 0,52
Notice:
I saw an reddit post "Formula to detect if row values are increasing?" with a similar question. I liked the idea and I have tried to use it with my numbers, but don't get the formula to work/understand it fully.
I am not sure if it can be done in one array formula, because the possibility to have N/A values causes some additional complexity. I can suggest a solution with a helper column though. Say your list of values is in A1:A7, then you can get the sign of the difference between the value in A2 and the value in A1 as follows:
= IF( ISNUMBER( A2 ), SIGN( A2 - LOOKUP( 2, 1 / ISNUMBER( A$1:A1 ), A$1:A1 ) ), 0 )
if you put this formula in B2, you can drag this down to B7. Now if you compare the sum of B2:B7 with the number of increases you expect, you have your answer:
= SUM( B2:B7 ) = COUNT( A1:A7 ) - 1
Refer to this very helpful page to get an explanation of how to get the last non-blank (c.q. numeric) value in a range.
Related
I have a Selected Countries table in Calc Sheet with dropdown lists on each cell that allows me to select specific countries from a `Holidays table. I have written a formula in Cell E2 of Calc Sheet that selects the dates from those selected countries columns.
=IFERROR(INDEX(HolidayList[#All],ROW(HolidayList[#All]),TRANSPOSE(MATCH(CHOOSE({1;2;3;4;5},$A$2,$A$3,$A$4,$A$5,$C$2),TRANSPOSE(HolidayList[#Headers]),0))),"")
In column L, I have written a formula to merge the selected countries dates and create a single date column of Unique Distinct values (non-duplicates).
=IFERROR(SMALL(SelectedHolidays,ROW(INDIRECT("1:"&COUNT(SelectedHolidays)))),)
This formula automatically lists all the dates without me having to drag the formula down to each cell. I need someone to help me modify this formula to generate a single list of unique distinct dates column. I don't need a formula that i have to drag down to subsequent cells.
I have also listed on a NamedRanges Sheet, the named ranges i have created in the workbook.
Here is a sample workbook attached for your perusal.
Edit:
I was able to workout a unique list of dates without dragging down the formula using the FREQUENCY function. However, there are #Values (for duplicates) in the rows array produced by MATCH in formula. How do i exclude the #Values in this array?
=SMALL(MDHolidays,IF(FREQUENCY(MDHolidays,MDHolidays)>0,MATCH(MDHolidays,MDHolidays,0),""))
For your first question, you can simply hide zero values by formatting your cells as m/d/yyyy;;. However, your formula can be amended to exclude the TRANSPOSE function...
=IFERROR(INDEX(HolidayList[#All],ROW(HolidayList[#All])-MIN(ROW(HolidayList[#All]))+1,MATCH(CHOOSE({1,2,3,4,5},$A$2,$A$3,$A$4,$A$5,$C$2),HolidayList[#Headers],0)),"")
For your second question, select cells L2:L33, since there's a maximum of 32 possible values, enter the following formula, and press Ctrl + Enter...
=IFERROR(SMALL(IF(SelectedHolidays>0,IF(ISNA(MATCH(SelectedHolidays,L$1:L1,0)),SelectedHolidays)),1),"")
EDIT
I'm a little confused as to why you're using MDHolidays, instead of SelectedHolidays. In any case, you can amend the the latest formula
you've posted as follows...
=IFERROR(SMALL(IF(FREQUENCY(IF(MDHolidays>0,MATCH(MDHolidays,MDHolidays,0)),ROW(MDHolidays)-MIN(ROW(MDHolidays))+1)>0,MDHolidays),ROW(INDIRECT("1:"&COUNT(MDHolidays)))),"")
We can get rid of zeros aka 1/0/1900 in column L by adding COUNTIF(SelectedHolidays,0) to row number, getting
=IFERROR(SMALL(SelectedHolidays,COUNTIF(SelectedHolidays,0)+ROW(INDIRECT("1:"&COUNT(SelectedHolidays)))),"")
We'll get a distinct Holidays range adding an additional column (for example, M) with an array formula
=IFERROR(INDEX(MDHolidays,MATCH(0,COUNTIF(M$1:M1,MDHolidays),0)),"")
EXCEL 365 Method -----------------------------
UNIQUE treats each row or column as a "tuple" and then compares each tuple, so when you put a matrix into it such as A1:C3, it looks either row-wise (e.g. {A1,B1,C1} vs {A2,B2,C2} ) or columns-wise (e.g. {A1;A2;A3} vs {B1;B2;B3} ) to determine if a tuple is unique. It does not look at each of the cells, so you have to multiplex the cells into a single column (or row) and then apply UNIQUE to that multiplexed range.
Here is a formula that you can put into L2 that will deliver a dynamic array of unique dates based on your XLS (thanks for sharing - that made this a lot easier to understand):
=LET( range, E3:I9,
Cols, COLUMNS( range ),
Rows, ROWS( range ),
iSeq, SEQUENCE( Rows * Cols,,0 ),
RowIndex, iSeq / Cols + 1,
ColIndex, MOD( iSeq, Cols ) + 1,
rawList, UNIQUE( INDEX( range, RowIndex, ColIndex ) ),
SORT( FILTER( rawList, ( rawList <> "" ) * ( rawList > 0 ) ) )
)
I set range = E3:I9 so that it includes up to Belgium in your output - not sure if that is what you are trying to achieve.
This LET formula takes in range as a variable and then it measures its dimension.
Modulation & Multiplexing
It then prepares the modulation so that range can be multiplexed into a single column. iSeq is the sequence that counts each cell in the range and that will be modulated vertically into RowIndex and horizontally into ColIndex. These are used to multiplex range by applying INDEX( range, RowIndex, ColIndex ).
Applying UNIQUE and Filtering
rawList applies UNIQUE to the multiplexed column to arrive at the unique values but... these will contain some undesirable outputs such as blank and 0 that need to be filtered, so the result is delivered as the filter of rawList. The final output is then sorted.
Also, with this formula, you can change your count of unique dates
formula in N2 to =COUNTA(L2#).
EXCEL 2013 Method (Plumhoff-Bartholomew) ----------------------------
Your MDHolidays is now going to become a set of helper cells using the same name that you have given it (let's not rename it for now or it will get confusing). We are going to use two more helpers to:
Generate a set of unique dates
that are free of zero-value dates
First, create two new named ranges:
k is an old-school sequence generator based on row
= ROW( MDHolidays ) - 1
unique.idx is boolean mask of k that eliminates duplicates, blanks and zero-dates:
= IF( ISNUMBER( MDHolidays ),
IF( ( MATCH( MDHolidays, MDHolidays , 0 ) = k ) * ( MDHolidays <> 0 ),
k ) )
These two can be created as named ranges without placing them anywhere. Just open Name Manager and create them as new names with the formulas above.
Now, you can create your output. You can test this in cell M2. It will be:
= IFERROR( INDEX( IF( MDHolidays > 0, MDHolidays ), SMALL( unique.idx, k ) ), "" )
If you like the result, then let's do a final clean-up. Rename MDHolidays to MCHolidays (merged, consolidated holidays) and then open Name Manager and replace your current dyn range formula for MDHolidays: =OFFSET(Calc!$L$2,0,0,COUNTA(Calc!$L:$L)-1) with your current (and very good) formula in L2 =IFERROR(SMALL(SelectedHolidays,ROW(INDIRECT("1:"&COUNT(SelectedHolidays)))),). This will virtualize those values so that they don't take up any cell-space.
Now you can reuse your old MDHolidays name by opening Name Manager, creating a new MDHolidays with the formula that is currently in M2 above. To complete the clean-up, change the formula in L2 to simply = MDHolidays and delete the formula in M2.
This method of teasing out UNIQUE was developed by Bernd Plumhoff and Peter Bartholomew.
I have a table of data in excel which has Time, Name, and Result columns.
My goal is to use formulas to generate a different, new table which shows the results for each Time (column) and Name (row) combination. This will later be used to generate a heatmap (the results are real numbers).
I am doing this by using a formula on each cell of the new table. An example from cell K5 in the new table is below:
=INDEX($AE$2:$AE$999, MATCH(1, INDEX(($A5=$X$2:$X$999)*(K$4=$V$2:$V$999),0,1),0))
Where $AE$2:$AE$999 is the Result column, $A5 is a name row in the new table, $X$2:$X$999 is the Name column, K$4 is a time column in the new table, and $V$2:$V$999 is the Time column.
The problem is that my table of data has multiple entries that have identical Name and Time combinations, but differing Result values. For these combinations, I would like for the formula to return the average of all nonzero results.
I think the current formula only returns the first match it runs into. I would like for this process to be autmated as possible as the original table of data will be changed frequently.
Screenshot showing the two tables.
The new table. The formula shown in G6 returns 0. I would like for it to return the average of 3.1 and 2.6.
One note: The text of your question is different from the images. I'm going to use the columns mentioned in the text of your message rather than the columns in the images.
It looks like what you're doing is calculating an average but only under certain conditions. Since you're working with multiple conditions, you would start by looking at the formula AVERAGEIFS().
In your case, for Cell G5, You want the average if any row in column X is India (A5) and that same row in column V is 6 (G4) and that same row in column AE is not zero.
So, at its base, the formula in G5 would look like this:
= AVERAGEIFS( $AE$2:$AE$999
, $X$2:$X999, "=India"
, $V$2:$V$999, "=6"
, $AE$2:$AE$999, "<>0" )
However, you want it to be both dynamic and flexible, to do that and keep Excel from messing with things as I move cells around, I make extensive use of the ROW() AND COLUMN() functions.
I think the final might look something like this
= AVERAGEIFS( $AE$2:$AE$999
, $X$2:$X$999, "=" & INDEX( $A:$A, ROW() )
, $V$2:$V$999, "=" & INDEX( $4:$4, 1, COLUMN() )
, $AE$2:$AE$999, "<>0" )
This can be pasted as is in any of the cells from B5 the the right and down, and should give you want you want in each cell. The formula will give you an error if the combination in the axes doesn't exist in the results table. So, you should wrap the whole thing in an error function and display what you want when that happens.
For reference
INDEX( $A:$A, ROW() ) Gives you the label in column A for the row in which the formula resides. So, for any cell in Row 5, this is "India".
INDEX( $4:$4, 1, COLUMN() ) gives you the label in row 4 for the column in which the formula resides. So, for any cell in column G, this will be "6".
If you hace Excel Version 365, the Dynamic Array functions make this simple
Times formula
=TRANSPOSE(SORT(UNIQUE(FILTER(U:U,(ROW(U:U)>1)*(U:U<>"")))))
Names Formula
=SORT(UNIQUE(FILTER(W:W,(ROW(W:W)>1)*(W:W<>""))))
Table formula
=IFERROR(AVERAGEIFS(AD:AD,AD:AD,">0",U:U,C4#,W:W,B5#),"")
If you don't have 365, then the table formula can be
=IFERROR(AVERAGEIFS($AD:$AD,$AD:$AD,">0",$U:$U,C$29,$W:$W,$B30),"")
and copied to the extents of the table. Create the header row/column by any means you choose
In an Excel sheet, I want to add values A1, C1, E1 and so on.
I tried with
=IF(MOD(ROW(), 2) = 0, 1, 0)
I want to add values of H2,J2,L2,N2,P2 and all alternative cells.
Like that I2,k2,m2,o2 abd all alternative cells. Image attached.
Excel Image
One way of solving your issue is to use SUMPRODUCT.
=SUMPRODUCT((A1:L1)*(MOD(COLUMN(A1:L1),2)<>0))
Replace A1:L1 with the relevant range on your worksheet.
It will be better if you can provide some sample data and expected output next time :)
You need an array formula. (I'll use A1:E1 as the example range). First we need to assign either 1 or 0 to each cell.
Mod(Column(A1:E1),2)=0
Then we multiply each cell by that 1 or 0 to give either the cell value or zero as the result
a1:e1*mod(column(a1:e1),2)=0
Then we Sum them
=SUM(A1:E1*(MOD(COLUMN(A1:E1),2)=0))
and finally we enter this as an array formula by entering it using Control Shift Enter
Assuming that the range you want to add is A1:A10 try this FormulaArray
= SUM( $A$1:$A$10 * ISODD( ROW( $A$1:$A$10 ) ) )
or this if the range is A1:Z1
= SUM( $A$1:$Z$1 * ISODD( COLUMN( $A$1:$Z$1 ) ) )
I have a range of data where column N displays the unique order number values, column F contains an Action. If the Action value for any of the related order numbers is the same as any other for that group I want to mark these up as , rejected, false, 0 whatever so that I can remove them from the dataset.
In the example graphic I have manually entered True or False in Column Q, but as I have over 10,000 rows, I think I may need a simple formula.
Can someone please advise how to achieve this
Many thanks
You could check number of lines with the same combination of Action and Order No. with this formula:
=COUNTIFS(N:N;N2;F:F;F2)
it will give you number of occurences of the combination, so you just need to filter all numbers greater than 1 or change the formula to give rejected, 0, false or whatever you like if the value is greater than 1.
In a new column, creat concatenate of column F and column N, For example, the new column is R then in cell Q1 put the value 1 and starting from Q2 paste this formula =IF(R1=R2,Q1+1,1)
Once the formula is dragged you can keep only one occurrence of the concatenated value and delete other.Snip from the Excel file
2nd snip attached here
Requirements:
Flag as Delete, all Order numbers with a duplicated Action value.
Assuming the data is located from rows 2 to 10105 (over 10,000 rows).
Solution – Array Formula:
This Array Formula will return (eventually) the required results:
= IFERROR( IF( MATCH( $N28,
IF( COUNTIFS( $N$7:$N$10105, $N$7:$N$10105, $F$7:$F$10105, $F$7:$F$10105 ) > 1, $N$7:$N$10105 ), 0 ) > 0,
"Delete" ), "" )
Unfortunately, the performance of an Array Formula pointing several times to a range of over 10,000 cells will be extremely slow.
To test the Array Formula over a much smaller range (24 rows only) enter this version of the formula in Q2 then copy it to Q3:Q25:
= IFERROR( IF( MATCH( $N2,
IF( COUNTIFS( $N$2:$N$25, $N$2:$N$25, $F$2:$F$25, $F$2:$F$25 ) > 1, $N$2:$N$25 ), 0 ) > 0,
"Delete" ), "" )
Solution – Standard Formulas:
The alternative solution would be to use two columns to flag the required records:
To identify the orders with duplicated Action, enter this formula in Q2 then copy it to Q3:Q10105:
= IF( COUNTIFS( $N$2:$N$10105, $N2, $F$2:$F$10105, $F2 ) > 1, $N2, "" )
To flag as Delete all Order numbers identified in step 1, enter this formula in R2 then copy it to R3:R10105:
= IFERROR( IF( MATCH( $N2, $Q$2:$Q$10105, 0 ) > 0,"Delete" ), "" )
I am trying to implement something similar to what is explained in this article:
http://exceltactics.com/make-filtered-list-sub-arrays-excel-using-small/
For this example, column B has Text, column c has integer values, and column d has text
The formula below works for filtering on values that are >= 1 in column C of my data:
=IFERROR(
INDEX(
B$2:B$11,
SMALL(
IF(
$C$2:$C$11>=1,
ROW(B$2:B$11)-ROW(B$2)+1
),
ROWS(B$2:B2)
)
),
""
)
I would like to replace that line with a search function that filters based the text content of a cell (from column D). The following works on a single line (returns 0 if "a" is not contained in the cell, otherwise a value greater than 0).
=IFERROR(SEARCH("a",$D2),0)
However, combining it with the first function doesn't work:
=IFERROR(
INDEX(
B$2:B$11,
SMALL(
IF(
IFERROR(SEARCH("a",$D$2:$D$11),0)>=1,
ROW(B$2:B$11)-ROW(B$2)+1
),
ROWS(B$2:B2)
)
),
""
)
What am I missing from this formula?
There is nothing wrong with the formula IMHO. It worked for me, but I did have problems when I tried to change the original formula in-place with the range selected. If you start off in a new area in the worksheet or just select the top cell in the original range and then pull it down once you've changed it, it's fine. With the range selected, it didn't change the final B2 to B3 etc. as I pulled it down, so just kept getting the first row number repeated.
BTW don't need the ">=1" in the modified part of the formula because any match will give a result >0 which is equivalent to "true"
IFERROR(SEARCH("a",$D$2:$D$11),0)
See also suggestion for changing the array formulae to ordinary ones before changing them
Changing array formulae