Converting an array formula from MS Excel to Google Sheets - arrays

I am at my tethers end on a question and was hoping someone on here could point out the simple mistake I am making.
I have a formula that I am using in an excel spreadsheet that works fine but when I import into Google Sheets it ceases to work.
The formula that works in excel is
{=INDEX('2009-2010'!D2:D20,MIN(IF(SUBTOTAL(3,OFFSET('2009-2010'!D2,ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2),0)),ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2)+1)))}
and the way I try and use it in sheets is
=ArrayFormula(INDEX('2009-2010'!D2:D20,MIN(IF(SUBTOTAL(3,OFFSET('2009-2010'!D2,ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2),0)),ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2)+1))))
But instead of doing what it is meant to (which is displaying the top visible cell on column 'D' of another worksheet called '2009-2010') it just inserts the whole column.
I have tried a couple work arounds but I am in over my head - any assistance would be fantastic!
Somewhat surprisingly I have not been able to find anything(anywhere) about someone trying to do the same function on Google Sheets...?!

This is an oldie, but if someone is still interested one could use this formula instead, in both Excel and Spreadsheet:
=INDEX('2009-2010'!D2:D20,MIN(IF('2009-2010'!D2:D20>0,ROW('2009-2010'!D2:D20)-ROW('2009-2010'!D2)+1)))
The IF('2009-2010'!D2:D20>0 part can also be changed to <>"" if the values are texts.
The problem is Spreadsheet doesn't treat all array formula scenarios the same way Excel does. For example Excel calculates the CountA for each item and returns an array of 0 and 1, and Spreadsheet counts the whole array and returns one count result.
This formula is also more efficient by avoiding the OFFSET volatile function.

Related

Applying array formula for rows with existing data

I have trouble creating automation using Google Sheets. I use array formula for converting duration format from one column, to make it understandeable for Google Data Studio, however, my autiomation, when there's no existing project, needs to append a new row. But if there's an array formula applied to a column, it has created 0 values for 1000 rows, and my new row gets appended as 1001. How to fix that?
Maybe I could somehow limit the array formula to work only if there's data in the row?
I tried to find other variant of array formula from here, but none of these worked,
https://support.google.com/docs/table/25273?hl=en
I could use some help. Thanks before.
Here's my spreadsheet, that I'm working on
https://docs.google.com/spreadsheets/d/1zWxvwNhCExy7_9tvgJ0lo4nBmYac51NMqaqzh8kR4H4/edit?usp=sharing
Array formula applied to last column creates rows for non-existend data
use:
=ARRAYFORMULA(IF(E2:E="";;SECOND(E2:E)+MINUTE(E2:E)*60+HOUR(E2:E)*3600))

Excel Formula: How to loop through an array and check if part of another list

I am wondering if it is possible - using an Excel formula (no vba) - to loop through a list with values and check if those values are in another list. The idea is to use this to come up with a sum pulling data from the first list while the second list sets the conditions. Please see below picture. I was thinking that this might work with sumproduct including an if-statement. Any ideas?
This should work (F1):
=SUM(SUMIF(Table1[Item],Table2[Included],Table1[Amount]))
but you may need to array-enter it or use SUMPRODUCT instead of SUM in pre-365 versions of Excel.
If you wanted to match ? literally rather than as a wild card standing for any single character you would need F2:
=SUM(SUMIF(Table1[Item],SUBSTITUTE(Table2[Included],"?","~?"),Table1[Amount]))
and similarly for *.

Excel sum across multiple sheets with criteria array

I have a workbook with several sheets, each containing a large amount of data formatted identically. What I'd like to do is enter a formula on a summary sheet that sums data from across the data sheets, selecting the data to sum based on an array of criteria.
The list of sheets is named 'AdHoc_Sheets' and the list of criteria is named 'Uncontrollable_Compensation'.
First attempt:
=SUMPRODUCT(SUMIF(INDIRECT("'"&AdHoc_Sheets&"'!"&"C:C"),A40,INDIRECT("'"&AdHoc_Sheets&"'!"&"E:E")))
This works well when only a single criteria (in this case 'A40') is needed. The challenge I'm finding is changing that to be an array of criteria.
Second attempt:
={SUMPRODUCT(SUM(IF(ISERROR(MATCH(INDIRECT("'"&AdHoc_Sheets&"'!"&"C:C"),TRANSPOSE(Uncontrollable_Compensation),0)),0,INDIRECT("'"&AdHoc_Sheets&"'!"&"E:E"))))}
Which returns a zero when it's not CSE'd and an #N/A error when it is CSE'd. Something about the dynamics of juggling the arrays is messing me up, and I can't quite tell if I need to turn to MMULT or some other method. Thanks in advance.
Assuming that the entries in column C are text, not numeric, array formula**:
=SUM(IF(ISNUMBER(MATCH(T(OFFSET(INDIRECT("'"&AdHoc_Sheets&"'!"&"C1"),TRANSPOSE(ROW(C1:C100)-MIN(ROW(C1:C100))),0)),Uncontrollable_Compensation,0)),N(OFFSET(INDIRECT("'"&AdHoc_Sheets&"'!"&"E1"),TRANSPOSE(ROW(C1:C100)-MIN(ROW(C1:C100))),0))))`
With such a construction you cannot 'get away' with arbitrarily referencing entire columns without detriment to performance. Hence my choice of range from row 1 to row 100, which obviously you can change, though be sure to keep it as small as possible.
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).

Changing arrays to direct links with VBA

Can anyone help me with a peice of VBA code that I can run that will change an array block into direct links to cells.
Basically the problem is that I have spreadsheets that other people have constructed and they are full of arrays linking to other sheets. I have to format them and add extra rows etc and arrays are not very flexible in this respect and I don't want to waste 3 or 4 days relinking everything.
Any help would be appreciated.
If there are array formulas in your worksheet they cannot be converted to direct links.
Cells in an array formula must always be adjacent - you can't have intervening cells that are not part of the array. That's just the way array formulas in Excel work.
You can try to convert to values, make your changes & then reenter the array formulas.

Matlab Multidimensional Arrays with string + Exporting to Excel

i have a code that works on all files in folder and analyise it and come then export results into excel sheet.
My question is, by the end i alot of excel sheets and i need to combine them all together (i also need them separate) so i do this manualy and its really painfull and time wasting !
So i want to ask is there a way to create an array to save the results of each analysis my code process and export all at the end to one excel file.
Example of my code Workflow:
Read files in current dir
Open files one by one.
Do math equations and get results into 2 arrays amp[] signal[] (both are equal in size)
Export results into Excel using
xlswrite([b '.xls'],[amp' signal'],1);%%b=file name (example.avi ==> example.avi.xls)
And so on.
So i want to save the results after that to array with the filename and at the end past all into 1 excel sheet with the file name on top of each column :)
I dont know why i'm having a brain block on how to do it !
Thanks alot for your help in advance
Xlswrite supports that you give a start point or range where you want to put your data. See Xlswrite.
You can quickly calculate the column name using this.
But you must be aware that excel only supports 255 columns and 1024 rows in a sheet. This happened often to me and then one gets a very uninformative error.

Resources