• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Formula for finding sum of first 3 Numbers

Hi All,

I want to find out the sum of first 3 non-blank cells. If there are more than 3 cells in that particular row means we should do the summation only for first 3 occurrences. Sample file attached.

Thanks
santhosha
 

Attachments

  • Book1.xlsx
    159.4 KB · Views: 3
Santhos,

I propose the following array formula,

=SUM(IFERROR(INDEX(B4:M4,SMALL(IF(B4:M4<>"",COLUMN(B4:M4)-1),1)),0),IFERROR(INDEX(B4:M4,SMALL(IF(B4:M4<>"",COLUMN(B4:M4)-1),2)),0),IFERROR(INDEX(B4:M4,SMALL(IF(B4:M4<>"",COLUMN(B4:M4)-1),3)),0))

Paste in Cell N4, press Ctrl+Shift+Enter to calculate as array, drag to fill all 27000 rows.

Attached.
 

Attachments

  • Santhos1.xlsx
    160.2 KB · Views: 1
Santhos,

We recently had a very similar need in our office, and I found another solution (following on John Jairo's):

=SUM(INDEX(A4:M4,,N(IF(1,IFERROR(SMALL(IF(B4:M4>0,COLUMN(B4:M4),""),{1,2,3}),0)))))

Still an array formula, but considerably more concise than my first suggestion. Sorry so late...

See attached.
 

Attachments

  • Santhos2.xlsx
    160.2 KB · Views: 2
Hi Santhos,

It is also possible without CSE ,
=SUM(B4:INDEX(INDEX(B4:M4,,AGGREGATE(15,6,COLUMN(B4:M4)-1/(B4:M4<>""),IF(COUNT(B4:M4)>3,3,COUNT(B4:M4)))),,0))

David
 
Back
Top