Sum of last 5 cells in a row with numbers (no blank)

Hi, I have a simple sheet with name of players on each row and their scores following in the columns after. I would like to add the scores from the last 5 round they participated in (non blank).
I have searched and tried numerous tricks with offset and index but cannot get it to work.
Can anyone help me please?
My data looks something like this:

Round, 1, 2, 3, 4, 5, 6, 7, 8, 9,
Player A, 4, 2, , 4, 3, 4, 4, , 3,
Player B, 3, , 2, 3, 4, , 3, 3, 4,
Player C, , 2, 3, 2, 2, , 2, ,

So for player A I wish to get the sum for the last 5 (4, 3, 4, 4, 3), round 8 is blank and should be ignored. How can I get this?

What is the max score a player can score in a round?

Max points is 30.

Hallo

=SUM(OFFSET($A2;0;LARGE(IF($B2:$J2<>"";COLUMN($B2:$J2);"") ;5)-1 ;1;COLUMN(K2)-LARGE(IF($B2:$J2<>"";COLUMN($B2:$J2);"") ;5) ))

sum_last_5_non_empty.ods (13.2 KB)

of course much simpler with:

=SUM(INDEX($A2:$J2;;LARGE(IF($B2:$J2<>"";COLUMN($B2:$J2);"");5)):$J2)

sum_last_5_non_empty2.ods (13.2 KB)

edit: last not least, a solution without the hassle of explicit array-context:

=SUMPRODUCT($B2:$J2;COLUMN($B2:$J2)>=LARGE(IF($B2:$J2="";"";COLUMN($B2:$J2));5))
4 Likes

This works! I’ll try to get my head around how, but it works. Many thanks!!

that’s not easy:
i have used rows auxiliary to turn inside out the no. of laps and count up without empty cells
sorry/pardon the file is nominated in /deutsch/
1_LibreOffice-CALC_SUMMEWENNS_Summieren der ausgewählten Runden-Ereignisse-v0001.ods (25.0 KB)

This is not an automatic method.

K2: ="="&REGEX(TEXTJOIN("+";1;B2:J2);"([0-9]*\+){4}[0-9]*$")
Paste K2:K4 as unformatted text with [x] Evaluate formulas in L2.
Sum of last 5 cells.ods (11.1 KB)
imagen

2 Likes

You may be interested in this variant:
disask98961AddLastFiveNumbersPerRow.ods (33.5 KB) (See below.)
Generally I would suggest to insert new rounds at the left end of the scores range and then to look for the first 5 valid results.
The totals should anyway be at the beginning (here left column, often top row).
=== editing ===
Thanks to @LeroyG who made me aware of an error occurring in the first two rows of my previouisly attached example. Some references were interchanged due to a subsequent exchange of the names by dragging (bad idea). Rectified version:
disask98961AddLastFiveNumbersPerRowRectified.ods (33.1 KB)

1 Like