[Solved] Unexpected result for SUM with multiplication
- 
				peanutaxis
- Posts: 8
- Joined: Sat Oct 10, 2020 3:45 am
							 [Solved] Unexpected result for SUM with multiplication
						[Solved] Unexpected result for SUM with multiplication
		
													
						
			
			
			
			Hi,
Anyone know what it going on with the sum plus multiplication in the attached? I can't work it out.
Thanks,
p
Title Edited. A descriptive title for posts helps others who are searching for solutions and increases the chances of a reply (robleyd, Moderator).
			
			
													Anyone know what it going on with the sum plus multiplication in the attached? I can't work it out.
Thanks,
p
Title Edited. A descriptive title for posts helps others who are searching for solutions and increases the chances of a reply (robleyd, Moderator).
					Last edited by Hagar Delest on Sat Jun 15, 2024 2:34 pm, edited 1 time in total.
					
Reason: tagged solved.
			
						
							Reason: tagged solved.
OpenOffice 4.1.6 Windows 10
			
						Re: What is going on here?
Code: Select all
=SUM(E5:E14)*2Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 25.8.2.2; SlackBuild for 25.8.2 by Eric Hameleers
---------------------
Tech support noun: A person who does precision guesswork based on unreliable data provided by those of questionable knowledge.
			
						Apache OpenOffice 4.1.15
LibreOffice 25.8.2.2; SlackBuild for 25.8.2 by Eric Hameleers
---------------------
Tech support noun: A person who does precision guesswork based on unreliable data provided by those of questionable knowledge.
- 
				peanutaxis
- Posts: 8
- Joined: Sat Oct 10, 2020 3:45 am
Re: Unexpect result for SUM with multiplication
Thanks, but why does it come up with the result of 4?
			
			
									
						
							OpenOffice 4.1.6 Windows 10
			
						Re: Unexpect result for SUM with multiplication
I suppose that your formula will be interpreted asThanks, but why does it come up with the result of 4?
Code: Select all
=SUM(E5;E14*2)Tibor Kovacs, Hungary;  LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
			
						PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
- Hagar Delest
- Moderator
- Posts: 33482
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: Unexpect result for SUM with multiplication
=SUM(E5;E14*2) would have returned 6 (2 + 2 x 2).
There was a similar topic not long ago. The syntax is not the one expected by AOO in the case of an operation on the range address. It seems that AOO/LO take the last cell to proceed with the operation.
I tag the topic as solved since it was a mere syntax error.
			
			
									
						
							There was a similar topic not long ago. The syntax is not the one expected by AOO in the case of an operation on the range address. It seems that AOO/LO take the last cell to proceed with the operation.
I tag the topic as solved since it was a mere syntax error.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE Faye) and 24.8 portable on Windows 11.
			
						- MrProgrammer
- Moderator
- Posts: 5347
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: [Solved] Unexpected result for SUM with multiplication
You asked Calc to perform the multiplication first. That operator multiplies one multiplicand by one multiplier. Your multiplier is 2. But your multiplicand is a range of ten cells. How does Calc know which one of them to use? It picks the one in the same row as your formula in G14. So it uses E14, which has a value of 2. 2 times 2 is 4. The other values in E5 through E13 were ignored. The single value 4 was passed to SUM. The sum of a single number is just that number. Thus the formula result is 4.peanutaxis wrote: ↑Sat Jun 15, 2024 8:16 am Thanks, but why does =SUM(E5:E14*2) come up with the result of 4?
In this formula the SUM function is performed first because Calc can't multiply numbers until it knows their values. Unlike the multiplication operator, the SUM function does support a range. The sum of E5 through E14 is 20. 20 times 2 is 40, the result of the formula.Calc Help wrote:SUM(number1; number2; ... number30)
• number1 to number30 are up to 30 numbers or ranges of numbers whose sum is to be calculated.
Yes, if the formula uses a semicolon instead of a colon. The multiplication operator is performed first because the SUM function needs to know what numbers are to be summed. E14 times 2 is 4. The SUM function then adds number1 (E5 with value 2) to number2 (that product with value 4). The result of the formula is 6.
If this solved your problem please go to your first post use the Edit ☐ button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.
[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
			
						AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
Re: [Solved] Unexpected result for SUM with multiplication
@MrProgrammerMrProgrammer wrote: ↑Sat Jun 15, 2024 4:55 pmYou asked Calc to perform the multiplication first. That operator multiplies one multiplicand by one multiplier. Your multiplier is 2. But your multiplicand is a range of ten cells. How does Calc know which one of them to use? It picks the one in the same row as your formula in G14. So it uses E14, which has a value of 2. 2 times 2 is 4. The other values in E5 through E13 were ignored. The single value 4 was passed to SUM. The sum of a single number is just that number. Thus the formula result is 4.peanutaxis wrote: ↑Sat Jun 15, 2024 8:16 am Thanks, but why does =SUM(E5:E14*2) come up with the result of 4?
Is that a case of intersection (mentioned e.g. in AOO Help)?
⠀
Example:
⠀
OpenOffice 1.1.5 – 4.1.15
LibreOffice 3.3.0.4 – 25.8
Windows 7,10,11 64-bit
			
						LibreOffice 3.3.0.4 – 25.8
Windows 7,10,11 64-bit
- Hagar Delest
- Moderator
- Posts: 33482
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: [Solved] Unexpected result for SUM with multiplication
User not aware of the syntax I guess (would not be the first ime).MrProgrammer wrote: ↑Sat Jun 15, 2024 4:55 pm But your multiplicand is a range of ten cells. How does Calc know which one of them to use?
Ah, that was it, thanks. Same row that looks like the default intersection mentioned by cwolan when there is nothing to define an intersection.MrProgrammer wrote: ↑Sat Jun 15, 2024 4:55 pm It picks the one in the same row as your formula in G14.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE Faye) and 24.8 portable on Windows 11.
			
						Re: [Solved] Unexpected result for SUM with multiplication
If you enter your original formula as an array formula, i.e. with Ctrl+Shift+Enter, it will show 40 as the result.
			
			
									
						
							AOO 4.1.15 & LO 25.2.5 on Windows 10
			
						- MrProgrammer
- Moderator
- Posts: 5347
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: [Solved] Unexpected result for SUM with multiplication
Yes. It is explained in Using Arrays → Functions not expecting array parameters → If it is a range → For a single row or a single column range. In this context, the multiplication operator can be regarded as a function which does not expect array parameters. E5:E14 is a single column range, so the intersection is made with the current cell's row. If the intersection of a range and the current cell's row/column is null, or if the intersection is more than one cell, the result is #VALUE!. Otherwise the intersection is a single cell whose value is the value of the range in non-array context.Hagar Delest wrote: ↑Sat Jun 15, 2024 6:54 pm Same row that looks like the default intersection mentioned by cwolan when there is nothing to define an intersection.
Fine for you and me. I knew that but didn't mention it because array formulas are an advanced topic. I do not recommend that beginners use them since they can be difficult to understand and have many quirks and issues, some of which are mentioned at the bottom of the link above. I know of cases where array formulas behave strangely and have helped people in topics who have bumped into them. The best way for a beginner to perform this particular calculation is with =SUM(E5:E14)*2, not an array formula. The question in this topic suggests to me that peanutaxis does not understand many of the very basic Calc concepts (like when ranges are allowed in formulas) and doesn't need any additional complexity now.
I will concede that there are some situations where an array formula is the only reasonable way to perform a calculation, but this is not one of those. Multiplication distributes over the addition from SUM and can be moved to the outside. If the operator inside the function were addition instead of multiplication =SUM(E5:E14+2) would either need an array formula, =SUMPRODUCT(E5:E14+2), or SUM() and a helper column with the incremented values. For a beginner I would suggest the latter, even though I wouldn't normally use a helper column myself. This is a case of Do as I say, not as I do. I didn't know, until creating the link, that the original appearance of that phrase is the New Testament.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
			
						AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).



