Sum product help

%3CLINGO-SUB%20id%3D%22lingo-sub-1597621%22%20slang%3D%22en-US%22%3ESum%20product%20help%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1597621%22%20slang%3D%22en-US%22%3EHello%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20a%20column%20of%20data%20containing%20numbers.%20Some%20cells%20contain%20multiple%20numbers%20separated%20by%20commas.%3CBR%20%2F%3EExample%3A%3CBR%20%2F%3E1%3CBR%20%2F%3E2%2C3%2C4%3CBR%20%2F%3E11%2C4%2C6%2C8%3CBR%20%2F%3E%3CBR%20%2F%3EMy%20goal%20was%20to%20find%20the%20frequency%20that%20the%20number%20one%20is%20listed%20first%20in%20each%20cell.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20used%20this%3A%20%3DSUMPRODUCT(-%20-%20(LEFT(A1%3AA100)%3D%E2%80%9C1%E2%80%9D))%3CBR%20%2F%3E%3CBR%20%2F%3EWhy%20does%20it%20only%20work%20for%20single%20digit%20numbers%3F%3CBR%20%2F%3E%3CBR%20%2F%3EIt%20works%20for%20the%201%2C%20but%20for%20example%20it%20doesn%E2%80%99t%20work%20for%2011.%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1597621%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1597663%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20product%20help%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1597663%22%20slang%3D%22en-US%22%3E%3CP%3EBecause%20the%20default%20second%20argument%20for%20LEFT%20is%201.%20So%2C%20LEFT(A1%3AA100)%20pulls%20only%20one%20character%20from%20the%20left.%20So%2C%26nbsp%3B%3DSUMPRODUCT(--(LEFT(A1%3AA100)%3D%221%22))%20will%20return%202%20(the%20two%20one's%20that%20are%20the%20first%20characters%20in%20the%20first%20and%20third%20item%20in%20the%20list).%3CBR%20%2F%3E%3CBR%20%2F%3EIf%2C%20in%20your%20example%2C%20there%20should%20be%203%20one's%2C%20then%20try%3A%3CBR%20%2F%3E%3DSUMPRODUCT(LEN(A1%3AA100)-LEN(SUBSTITUTE(A1%3AA100%2C1%2C%22%22)))%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20you%20wanted%20to%20count%20only%20the%20number%201's%20(excluding%201's%20that%20are%20part%20of%20a%20larger%20number%2C%20like%2011)%2C%20then%20I%20think%20this%20would%20work%3A%3CBR%20%2F%3E%3DSUMPRODUCT(LEN(%22%2C%22%26amp%3BA1%3AA100%26amp%3B%22%2C%22)-LEN(SUBSTITUTE(%22%2C%22%26amp%3BA1%3AA100%26amp%3B%22%2C%22%2C%22%2C1%2C%22%2C%22%2C%2C%22)))%3CBR%20%2F%3E%3CBR%20%2F%3EThough%20this%20formula%20would%20also%20work%20with%20SUM%20(array%20entered).%20It's%20not%20really%20really%20taking%20advantage%20of%20sumproduct's%20implicit%20array%20multiplication%20(it's%20just%20summing%20an%20array).%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1597876%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20product%20help%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1597876%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F763536%22%20target%3D%22_blank%22%3E%40Jbisca%3C%2FA%3E%26nbsp%3BWell%2C%20the%20LEFT%20function%20takes%20the%20first%20character%20if%20no%20number%20of%20characters%20is%20specified.%20when%20you%20do%20specify%20a%20number%20(e.g.%201%20or%202%20or%203)%20it%20takes%20either%20the%20first%2C%20the%20first%20two%20or%20the%20first%20three%20characters.%20It%20can%20not%20take%20the%20first%20for%20one%20cell%20and%2C%20for%20instance%20the%20first%20three%20in%20another.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20your%20Excel%20version%20supports%20the%20SEQUENCE%20function%2C%20perhaps%20the%20attached%20solution%20offers%20an%20acceptable%20work-around.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor
Hello,

I have a column of data containing numbers. Some cells contain multiple numbers separated by commas.
Example:
1
2,3,4
11,4,6,8

My goal was to find the frequency that the number one is listed first in each cell.

I used this: =SUMPRODUCT(- - (LEFT(A1:A100)=“1”))

Why does it only work for single digit numbers?

It works for the 1, but for example it doesn’t work for 11.
1 Reply

@Jbisca Well, the LEFT function takes the first character if no number of characters is specified. when you do specify a number (e.g. 1 or 2 or 3) it takes either the first, the first two or the first three characters. It can not take the first for one cell and, for instance the first three in another.

 

If your Excel version supports the SEQUENCE function, perhaps the attached solution offers an acceptable work-around.