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.
Sumproduct(array1,array2) is an excel formula that performs the dot product.
=Sumproduct({1,2,3},{7,0,5})
results in 1*7 + 0*2 + 5*3 = 22
I want to replace the first array by values stored in non-stacked cells ( for example: A1,A3,B7) I tried
=Sumproduct({A1,A3,B7},{7,0,5})
but it doesn't work. It seems I can't create an array from non-stacked cells.
Can you please help me create an array of non-stacked cells in Excel?
Try this as an array formula entered with ctrl+shift+enter.
=SUMPRODUCT(CHOOSE(ROW(1:3), A1, A3, B7), CHOOSE(ROW(1:3), 7, 0, 5))
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.
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
Was using this formula SheetName!CellAddress
I need to import Data that is available on other 2 sheets namely (sheet2 and sheet3) into sheet 1 in a way such that
the row values will be alternate i.e one value from sheet 2 and other value from sheet 3 respectively
Have tried like this
=Sheet2!C2
=Sheet3!D2
when i dragged for other values i was get only values in the even cell like(c4,d4,c6,d6)
If i change the for formula to
=Sheet2!C1
=Sheet3!D1
i was get only values in the even cell like(c3,d3,c5,d5)
But what i need is continous cells in row( c1,d1,c2,d2,c3,d3...)
So what formula i need to use for getting this result
I am still not 100% clear on what the question is asking, so let me know if the below answer doesn't work for you.
It sounds like what you're looking for can be accomplished with OFFSET and clever use of IF statement.
Suppose your formulas will be in column A, starting in A2. Then enter the following formula into A2 (line split added for readability; remove it):
= IF(MOD(COUNTA(A$1:A1),2)=0, OFFSET(Sheet2!$C$1, COUNTA(A$1:A1) / 2, 0),
OFFSET(Sheet3!$D$1, COUNTA(A$1:A1) / 2, 0))
Then drag the formula down.
What it does:
MOD(COUNTA(A$1:A1),2)=0 - checks whether we're in odd row or even row.
COUNTA(A$1:A1)/ 2 - takes half of the number of non-empty cells immediately above the current cell.
OFFSET(Sheet2!$C$1, COUNTA(A$1:A1) / 2, 0) - takes the cell which is COUNTA(A$1:A1)/ 2 cells below Sheet2!$C$1.
Here's a fairly basic method:
Enter the first two formulas as Text - you can either do this by formatting the cell number as text or preceding the formula by an apostrophe.
Select cells and fill down to get:
=Sheet2!C2
=Sheet3!D2
=Sheet2!C3
=Sheet3!D3
=Sheet2!C4
=Sheet3!D4
...
Select the column and choose Data|Text to Columns|Finish to change text to values.