Excel: How to use an Array to concatenate strings that are next to a criteread section (If function) - arrays

Good Day Everyone
I have an Excel sheet as bellow in two columns. I know how to use an array if function with sum to add up all values next to a column that has met the criterea as in {=sum(if(A1:A5="YES",B1:B5)} but how to go about doing it with strings and concatenate so that they show the result as below
Thanks for Any Help
The Excel array
Edit: I know there is a easy VBA solution, but was wondering if there is an excell way since there is an easy solution if it was values and not strings.

If I'm assuming you don't want the relatively easy VBA solution where you recurse through the initial list and concatenate the answers then you could put the following into B8:
=IFERROR(INDEX(Sheet1!$A$1:$A$6,SMALL(IF(Sheet1!$B$1:$B$6=$A8,ROW(Sheet1!$B$1:$B$6)-ROW(Sheet1!$B$1)+1),COLUMNS($B1:B1))),"")
You'd have to drag it across as it'll put them in separate columns but then you should be able to concatenate them into a single column afterwards.
You have to have Ctrl and Shift held down when inputting as it's an array formula.

Activate iteration in the options. The maximum number of iterations must be equal to or greater than the number of lines.
Add =IF(D1=100;1;D1+1) to cell D1
This is the formula in cell E1 for the Stark houses:
=IF(D1=1;"";IF(D1-1>COUNTIF(B:B;"Stark");E1;E1&INDEX(A$1:A$100;SMALL(IF(B$1:B$100="Stark";ROW($1:$100));D1-1))))
(I hope that I got the English names of the functions correctly.)
I missed one information: You must enter the function as an array function.
Thanks go to http://www.excelformeln.de/formeln.html?welcher=155

Was really Strugling to get it right and eventualy got an answer from a stackoverflow question on how to concatenate whole columns.
Sorted the data via B and then used =TRANSPOSE(A4:A6)
Then Used F9 on the function to get this line ={"Mansion1","Mansion 2","House 3"}
Copied and Concatenate and just remove the {
But this was not ideal as the data set I want to use this on is 2500+ lines :(
Manualy did it though :( :( but will try the above answers for future use.

Related

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 Formula to Sum Delimited Values in Cells

I have two general columns of text stored in Excel, where each cell contains numbers delimited by a semicolon (delimited only if multiple numbers present).
The two Excel columns always have the same number of values delimited.
I'm trying to figure out how to sum (subtract) each value to form a delimited list in another column, especially using Excel Functions only (e.g. no VBA if possible).
How can I do this? I'm missing VBA's split function from the Excel Formulas.
Note: Value - Offset = (Desired Result)
Use this Array Formula:
=TEXTJOIN(";",TRUE,TRIM(MID(SUBSTITUTE(A2,";",REPT(" ",99)),(ROW($A$1:INDEX(A:A,LEN(A2)-LEN(SUBSTITUTE(A2,";",""))+1))-1)*99+1,99))-TRIM(MID(SUBSTITUTE(B2,";",REPT(" ",99)),(ROW($A$1:INDEX(A:A,LEN(B2)-LEN(SUBSTITUTE(B2,";",""))+1))-1)*99+1,99)))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting Edit mode.
It requires the the number of inputs match the number of Offsets
One could also use:
=TEXTJOIN(";",,FILTERXML("<t><s>"&SUBSTITUTE(A2,";","</s><s>")&"</s></t>","//s")-FILTERXML("<t><s>"&SUBSTITUTE(B2,";","</s><s>")&"</s></t>","//s"))
I know, I am late, and it has already been solved, while searching in here, to solve an equation found this post. Both the solutions posted above by SCOTT CRANER Sir & JvdV Sir worked for me, I am just adding an alternative which works with MS365 using TEXTSPLIT()
• Formula used in cell D2
=TEXTJOIN(";",,TEXTSPLIT(A2,";",,1)-TEXTSPLIT(B2,";",,1))

Excel Array formulas details and guidance needed (INDEX,MATCH and SUM/COUNTIF)

So I'm having difficulties understanding fully how arrays works and when they are used by excel and specifically what happens in the background.
From reading the past few hours I understand that one of the reasons my Index Match doesn't work without array is simply because its a multicriteria Match that I use as below:
{=INDEX(D30:E36,MATCH(F33&G33,B30:B36&C30:C36),2)}
From what I understand the reason is that Match returns a {x,y} result which classifies it as an array formula. But considering the point is to get a row number, if the row I'm looking for is 5 then Match will return a {5,5} for row number for Index. And then Index interprets this as just 5? or what exactly happens in the background here?
Then I found an article which showed how to circumvent the array formula and not need ctrl+shift+enter as shown below. How does the below change things and what happens in the background?
=INDEX(D30:E36,MATCH(F33&G33,INDEX(B30:B36&C30:C36)),2)
The below is a an array SUM/COUNTIF formula which counts unique cells only which does not work without array brackets. Why is that and how does it work? It involves maths so I'm not sure.
{=SUM(1/(COUNTIF(A1:A5,A1:A5)))}
Thank you!

SUM with IF conditions for cells containing both strings and numbers

I've got a bigger table with one column that I want to focus on, containing designation and a number. I want to simply sum the numbers that meet the criteria based on a designation.
For the simplification, I made an exercising sheet (on the pic) where I split second column into two - one string and one numeric. Since my file is quite large with many columns that would need this it would be inconvenient.
In the left column it's easy to solve the problem, it could be even easier with simple SUMIF function, but an array SUM(IF... function is, at least I think, only viable option here.
So I solved the first table with array function, but what confuses me is how to modulate the TRUE statement. Simple replacement of C:C
with
VALUE(MID(F:F;4;4))
which would format my cells to get the numbers from string does not work that way - returns zero in E12 field. F12 is just application of string to number for last cell, F10.
THIS formula does not work, even adapting to different versions of the tool.
I could use VB but if possible anyhow I would like to avoid it since parts will be shared on mobile phones.
Any ideas? Thanks a lot!
Left table was split, right original format
The array formula which you used can be replaced by the SumIf formula like below...
=SUMIF(B:B,"B",C:C)
Also without the helper column, you can use the Sumproduct formula to achieve the desired output.
But don't refer the whole column in the formula like in the above SumIf formula.
Try this..
=SUMPRODUCT((B1:B10="B")*MID(F1:F10,FIND(",",F1:F10)+1,255)*1)
Change the ranges as per your requirement but remember to make them equal in size.

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.

Resources