Mode of an horizontal text array in Excel - excel

I have a table where I would like to know the most common value of every row, all the data is text.
expected result is column D in picture
Example in picture.
I have tried this formula but it doesnt work, i only get #Value error
=INDEX(P2:R2,TRANSPOSE(MODE.MULT(IF(ISTEXT(P2:R2),MATCH(P2:R2,P2:R2,0)))))

You can use following array formula:
=INDEX(A2:C2,MATCH(MAX(COUNTIF(A2:C2,A2:C2)),COUNTIF(A2:C2,A2:C2),0))
Array formula after editing is confirmed by pressing ctrl + shift + enter

MODE works on numeric data, so you can, for your example, use:
=CHAR(MODE(CODE(A2:C2)))

Related

SUM of multiple columns text in Excel

Is the first time writing a command in excel so I have no particular idea what I'm doing.
As you can see from the image I'm trying to get in the "All Stores" column all the Stores that have the "X" in them.
At the moment the command that I'm using is displaying the output of the first cell where it finds an "X".
I have looked at some examples that I found on this topic, but I didn't find something concrete. I've tried to do it with "SUMIF" and also I've tried to use "&" in from and after "B2", "C2", "D2", but all I got was an error.
Everything that I found on this topic was how to combine numbers.
In this particular example the expected result would be "Store1, Store3".
Thank you for your support!
Yyou could use the following:
=TEXTJOIN(", ",TRUE,IF(B2="x",B$1,""),IF(C2="x",C$1,""),IF(D2="x",D$1,""))
And populate down for other products
Though it could get unwieldy if you have a lot of stores. I'm pretty sure someone else will come up with a more clever answer, but I can't think of anything else at the moment.
In E2 enter the array formula:
=CHOOSE(COUNTA(B2:D2)+1,"",INDEX(B$1:D$1,MATCH("x",B2:D2,0)),TEXTJOIN(", ",TRUE,IF(B2:D2="x",B$1:D$1,"")),"All stores")
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
The logic is:
First of all, I image you have over several columns that you want to consider. SO you can get this date in a new worksheet by replacing "x" or a mark of choice using below formula:
=IF(A2<>"", A$1, "") just autofill to get all the values in the new worksheet.
Now focussing on the new worksheet. e.g.
Apply below formula to get the required result
=IF(COUNTA(H2:J2)-COUNTBLANK(H2:J2)=COLUMNS(H2:J2),"All Stories",TEXTJOIN(",",TRUE,H2:J2))
You can try this array formula:
=IFERROR(TEXTJOIN(",",TRUE,INDEX($A$1:$F$1,1,AGGREGATE(15,6,1/(B2:F2="X")*COLUMN(B2:F2),N(IF(1,ROW(INDIRECT("1:"&COUNTA(B2:F2)))))))),"")
To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.

Using Excel's SUMPRODUCT with SEARCH and ignoring blank cells

Suppose I have a row of cells that contain comma delimited strings like so:
I have figured out how to add the first character of each string using this formula:
=SUMPRODUCT(--(LEFT(C2:G2,SEARCH(",",C2:G2,1)-1)))
Now, I would like to extend the formula to the cell AA2, like so
=SUMPRODUCT(--(LEFT(C2:AA2,SEARCH(",",C2:AA2,1)-1)))
however, I cannot seem to get the it to ignore empty cells - it throws a #VALUE! error. I realize that I could simply update the formula each time I enter data in the subsequent cells, but that's not exactly efficient. I assume this throws an error because the SEARCH function returns a null value.
How might I get this to work?
You can try below modified formula:
=SUMPRODUCT(--(LEFT(C2:AA2&"0,",SEARCH(",",C2:AA2&"0,",1)-1)))
For right side you can use MID like below and check:
=SUMPRODUCT(--(MID(C2:AA2&".0",SEARCH(",",C2:AA2&",.0",1)+1,99)+0))
Your idea of searching for the comma is not needed if you only want to add the first character of each cell. Just grab the left-most single character.
Say we may have data from A1 to Z1 that may include some blank cells. Pick a cell and enter the array formula:
=SUM(IF(LEN(A1:Z1)>1,--LEFT(A1:Z1),0))
for example:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

Obtaining #NUM when using LARGE with dates array

I'm getting a #num error to a previously working formula.
Formula:
=LARGE(A19:A20,1)
FORMULA OUTPUT: #NUM!
A19: 3/20/2018
A20: 5/1/2018
I'm not sure why this isn't working anymore.
Regards,
If the data is Text and not true dates, use this array formula:
=LARGE(--(A19:A20),1)
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
NOTE:
This formula will work for both real dates and text that resemble dates. It is easy to see if the dates are real or not; just toggle Ctrl + `. Real dates will display their underlying numeric value, text date will remain unchanged.

Formula Result in Function Argument Window Different Than in Cell

I have the following array formula:
=MAX(COUNTIF(Sheet2!A$2:Sheet2!A$6,Sheet2!A2:Sheet2!A6))
Which is supposed to give me the count of duplicate entries in a small text column in a worksheet. I've put one duplicate entry to test the formula, and the result I should get is 2. Instead, once I ctrl+enter, the cell shows 0. However, when I click the formula button next to the cell content field, it shows Formula result = 2.
Calculation Options are set to Automatic (this is Excel 2010), and I have no idea why this is happening. Any ideas? Thanks.
Seems it was a keyboard problem with the shift or ctrl buttons stuck (: I clicked on the formula inside the formula argument window, then clicked ctrl+shift+enter and it added the curly brackets for the array formula and the result is now correct and updates correctly when the source data changes.

numbers treated as text giving wrong values in index and sumifs

I'm indexing a table that somehow has numbers stored as text, here is a fragment:
{0\0\0\0\"110"\950\0\0\0\"3485"\0\0\0\"950"\0\0\0\0\0\100}
When I try to use sumifs for this range, i get wrong values. Is there any way to fix this in formula without changing the data?
This is the exact formula I'm using:
=SUMIFS(INDEX(INDIRECT("'"&"P_"&$C$3&"'!B9:BC100");MATCH($D6;INDIRECT("'"&"P_"&$C$3&"'!BC9:BC100");0););INDIRECT("'"&"P_"&$C$3&"'!B1:BC1");L$1))
You cannot use SUMIFS but there's a work-around.
Something like:
So if you have data like above, enter this array formula:
=SUM(IF(INDIRECT("A3:A5")=A$2,VALUE(INDIRECT("B3:B5"))))
by pressing Ctrl + Shift + Enter.
300 is entered as Text but you still get the correct total for all items equal to A$2 which is A.
Note: My local separator is , (not ; as in your example) so don't be confused.
Also, above is just an example, I'll leave the actual adaptation of your formula to you. HTH.
If you have ranges with numbers stored as text a good way to deal with this is to multiply your cells by 1 as you use them. Example below. You need to leave out the curly braces and press Ctrl+Shift+Enter to enter the formula, which tells excel to individually multiply each number by 1 before summing them (in my example)
Therefore, you might try the following formula with your data
{=SUMIFS(INDEX(INDIRECT("'"&"P_"&$C$3&"'!B9:BC100")*1;MATCH($D6;INDIRECT("'"&"P_"&$C$3&"'!BC9:BC100")*1;0););INDIRECT("'"&"P_"&$C$3&"'!B1:BC1");L$1))}
Note: I haven't tested this formula, but I did test that this method works with INDIRECT()

Resources