Cant Get formula to enter blank cells at end of column - arrays

I have data composed on chemicals and hyphened cells in column F of sheet1.
Using the formula in sheet2: =IF('Formulation card'!F7:F60="-","",'Formulation card'!F7:F60)
This works well to convert the hyphened cells to a blank cell if present in F7:F60 of the formula card.
At at end however I get a bunch of '0's entered where Blank non hyphenated cells are present.
I've tried to use an OR Statement as follows:
=IF(OR('Formulation card'!F7:F60="-",""),"",'Formulation card'!F7:F60)
Which to me reads if a - or a "" is present return "".
However doing this just returns all columns as Blank. I though I had got my head around using OR statements but apparently not.
If someone could point out whats wrong here that would be great. Let me know if you require more information.

Internally all given indices inside an OR() statement will be processed, however only one value of FALSE or TRUE will be returned depending if any of the calculations returned TRUE. Hence why your column will stay "empty". It's actually not empty, but full of zero-width strings.
You can circumvent that behaviour in Microsoft365 using some boolean structure:
=IF(('Formulation card'!F7:F60<>"-")*('Formulation card'!F7:F60<>""),'Formulation card'!F7:F60,"")

Related

getting google sheets to ignore the first X number of rows instead of writing empty strings to them

I have the following formula to automatically insert the date in column B if the corresponding cell in row A contains data
However there are already rows that have been filled out manually from before I decided to try automate this and I don't want to lose the data
so I have the following formula (note 5 is used here just for testing purposes. in final application there are more than 100 populated rows I am trying to skip over
=ArrayFormula(IF(ROW(B:B)=1,"Date",IF(ROW(B:B)<5,"",IF(A5:A<>"",TODAY(),""))))
however it keeps returning the following error
Error
Array result was not expanded because it would overwrite data in B2.
As far as I can tell this is because it is attempting to write an empty string to these cells. Is there a way to have it not do this and simply start from row X?
I tried to wrap the formula in an IfERROR statement but that did not work and as seen above I attempted start referencing only from cell 5 onward but tat didnt work either
=ArrayFormula(IFERROR(IF(ROW(B:B)=1,"Date",IF(ROW(B:B)<5,"",IF(A:A<>"",TODAY(),""))),""))

How to maintain true Blank Cells when copying a column

Problem: I have data in Column A as headings of some sort and in column B I have subheadings.Because of this column A has blank cells between the headings.
If I set Cell A1 in a second sheet to be equal to A1 on the first sheet and copy this throughout the blank cells return as '0'. This messes with formulas that rely on true blank cells.
I've attached and image to visually explain the problem.
To replicate the desired output and the problem:
Enter random data into columns A and B leaving blanks in column B.
In column C enter: =SUBSTITUTE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>'",,A1:B50)&"</s></t>","//s"),"'","")'
This Will return a correct result combining the heading and subheadings in a logical order.
.
However if you set say column E and F to equal Columns A and B respectively and enter the following in column G: =SUBSTITUTE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>'",,D1:E50)&"</s></t>","//s"),"'","")
The data will return correctly sorted but now with a bunch of 0s between each heading and subheading because the formula now includes cells that were originally blank as 0.
What I've Tried: Aesthetically you can set '0' Cells to not display 0 in advanced setting but as the name descries its still a 0 and just hidden but not from the formula. I have tried setting the cell to Text only to try and eliminate 0 but this has no affect as numbers are still recognised as text. I have also tried to eliminate 0 with the code =IF(E1="0","",E1) and =IF(E1="0",NA(), E1). This removes the 0 or adds N/A# but ultimately these cells are still recognised as such by the above formula and a 0 is entered or the formula fails.
Does anyone know how to make one column with blank cells equal to another and still maintain True Blank Cells and not 0s? Alternatively if anyone knows how I can modify my formula to ignore 0s that would be great too. I don't have any experience in VBA but I'm willing to learn/copy and paste a code that will remove this problem.
Any help is appreciated, or if you think its not possible let me know.
Please try this formula in your cell E2 and copy down.
=LOOKUP(2,1/($A$1:$A2<>""),$A:$A)
The opposite effect is achieved with this formula.
=IF(A2="","",A2)
The first formula will copy the header to each row even where the source is blank whereas the second produces a blank cell for a blank cell. Another ay is to allow the zeros to be written but suppress their display with a cell format or a universal setting (for the whole sheet) that suppresses display of zero values.
Did you mean you would like to use a condition in TEXTJOIN(), a nested IF():
Formula in D1:
=SUBSTITUTE(FILTERXML("<t><s>'"&TEXTJOIN("</s><s>'",,IF(A2:B13<>0,A2:B13,""))&"</s></t>","//s"),"'","")

How to arrange table data differently by using if, match, and index?

As shown in the attached image, I need to convert A2:D10 to the format of A12:E17. The 4 tables from F1 to AB12 are my experiments using if, match, and index. Same formula gets different results and it seems to be dependent on the row position of the tables. In My previous question, I was trying to pinpoint the problem to the if function.
What am I doing wrong here?
Thanks,
Lu
enter image description here
Again, as I said in your last question: The formula has not been array entered. Array formulas need to be confirmed with Ctrl-Shift-Enter.
Without that, the first array in the IF statement does not get resolved and the Match does not return the correct result.
Make use of the Evaluate Formula tool and step through the formula.
The merged cells don't help with the cell referencing. Unmerge the cells and fill in all the labels in row 1, then use this slightly amended formula and confirm it with Ctrl-Shift-Enter. Then copy across and down.
I hope that I get the English names of the functions right:
In D14 and following cells:
=INDEX($C$1:$C$5;MATCH(1;MMULT(($B$3:$B$10=$A14)*($A$3:$A$10=B$13);1);0))
The MATCH function tells which value (by number counted from the top) matches both conditions. The INDEX function returns this value from C1:C5.

Returning multiple adjacent cell results from an min array which may include multiple duplicate values

I'm trying to setup a formula that will return the contents of an related cell (my related cell is on another sheet) from the smallest 2 results in an array. This is what I'm using right now.
=INDEX('Sheet1'!$A$40:'Sheet1'!$A$167,MATCH(SMALL(F1:F128,1),F1:F128,0),1)
And
=INDEX('Sheet1'!$A$40:'Sheet1:!$A$167,MATCH(SMALL(F1:F128,2),F1:F128,0),1)
The problem I've run into is twofold.
First, if there are multiple lowest results I get whichever one appears first in the array for both entries.
Second, if the second lowest result is duplicated but the first is not I get whichever one shows up on the list first, but any subsequent duplicates are ignored. I would like to be able to display the names associated with the duplicated scores.
You will have to adjust the k parameter of the SMALL function to raise the k according to duplicates. The COUNTIF function should be sufficient for this. Once all occurrences of the top two scores are retrieved, standard 'lookup multiple values' formulas can be applied. Retrieving successive row positions with the AGGREGATE¹ function and passing those into an INDEX of the names works well.
    
The formulas in H2:I2 are,
=IF(SMALL(F$40:F$167, ROW(1:1))<=SMALL(F$40:F$167, 1+COUNTIF(F$40:F$167, MIN(F$40:F$167))), SMALL(F$40:F$167, ROW(1:1)), "") '◄ H2
=IF(LEN(H40), INDEX(A$40:A$167, AGGREGATE(15, 6, ROW($1:$128)/(F$40:F$167=H40), COUNTIF(H$40:H40, H40))), "") '◄ I2
Fill down as necessary. The scores are designed to terminate after the last second place so it would be a good idea to fill down several rows more than is immediately necessary for future duplicates.
¹ The AGGREGATE function was introduced with Excel 2010². It is not available in earlier versions.
² Related article for pre-xl2010 functions - see Multiple Ranked Returns from INDEX().
The following formula will do what I think you want:
=IF(OR(ROW(1:1)=1,COUNTIF($E$1:$E1,INDEX(Sheet1!$A$40:$A$167,MATCH(SMALL($F$1:$F$128,ROW(1:1)),$F$1:$F$128,0)))>0,ROW(1:1)=2),INDEX(Sheet1!$A$40:$A$167,MATCH(1,INDEX(($F$1:$F$128=SMALL($F$1:$F$128,ROW(1:1)))*(COUNTIF($E$1:$E1,Sheet1!$A$40:$A$167)=0),),0)),"")
NOTE:
This is an array formula and must be confirmed with Ctrl-Shift-Enter.
There are two references $E$1:$E1. This formula assumes that it will be entered in E2 and copied down. If it is going in a different column Change these two references. It must go in the second row or it will through a circular reference.
What it will do
If there is a tie for first place it will only list those teams that are tied for first.
If there is only one first place but multiple tied for second places it will list all those in second.
So make sure you copy the formula down far enough to cover all possible ties. It will put "" in any that do not fill, so err on the high side.
To get the Scores use this simple formula, I put mine in Column F:
=IF(E2<>"",SMALL($F$1:$F$128,ROW(1:1)),"")
Again change the E reference to the column you use for the output.
I did a small test:

Non-Native function returning an array - How to display the output

I apologise if this is a very simple question, but I am at a bit of a loss here.
A bespoke formula I want to use returns an array of values, as seen here:
But I cannot find a way to present this output in a cell separated format, only the first cell (39478) is returned.
There is a note included in the documentation: Hint: This function is a multiple result function. You MUST set an array for the output.
Whilst I understand I am going to need an array to display multiple results, I cannot find the method of doing so. Any tips?
If the bespoke formula wants to return an array of values, there are a couple of ways to get the results into multiple cells.
Put the formula into a cell and hit Enter↵. Next, select that cell along with several cells below it. Tap F2 then hit Ctrl+Shift+Enter↵. The successive values should fill the cells selected until an error (no more returns) is reached.
Put that formula into a cell and hit Ctrl+Shift+Enter↵. The formula should be wrapped in braces (e.g. { and }). If the correct relative and absolute cell addresses were used (e.g. $**A$1 or $**A1, etc) then you should be able to fill, copy or drag down the formula into successive rows.
Use an INDEX function to contain the array of returned values from the bespoke formula and peel off successive values using the row_num parameter.       =INDEX(<bespoke formula>, ROW(1:1))   Filled down.
Sooner or later, you will run out of rows to fill. An IFERROR function used as a wrapper can help avoid he display of errors.
If you want to put all of the values into a single cell, then a User defined Function (aka UDF) could concatenate the array into a single string. This last method is generally not recommended as it renders the values useless for anything other than display purposes.
Array formulas need to be finalized with Ctrl+Shift+Enter↵. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula.
Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum.
See Guidelines and examples of array formulas for more information.

Resources