Sumproduct returns wrong result

sadath

Active Member
Joined
Oct 10, 2004
Messages
262
Office Version
  1. 365
Platform
  1. Windows
following is the part of formula which returns wrong result...

SUMPRODUCT(IF(MOD(ROW(1:1),2)=0,-1,1)) result is 1 which is correct

SUMPRODUCT(IF(MOD(ROW(2:2),2)=0,-1,1)) result is -1 which is correct

SUMPRODUCT(IF(MOD(ROW(1:2),2)=0,-1,1)) result is 1, should be zero


why returns wrong result... any idea?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Why do you think the result should be zero ?

And why are you using SUMPRODUCT ?
Deleting the SUMPRODUCT element gives the same results.
 
Upvote 0
Hi
no idea why this returns wrong

=SUMPRODUCT(C1:C10*IF(MOD(ROW(1:10),2)=0,-1,1))

but this CSE works fine =SUM(C1:C100*IF(MOD(ROW(1:100),2)=0,-1,1)) thanks to 'steve the fish '
 
Upvote 0
Looks like there should be an easier way to produce the sequence but this works without CSE:

=SUMPRODUCT((MOD(ROW(C1:C10),2)=0)*(MOD(ROW(C1:C10),2)-2)+1,C1:C10)
 
Upvote 0
In short

SUMPRODUCT(IF(MOD(ROW(1:2),2)=0,-1,1))

Without CTRL + SHIFT + ENTER
ROW(1:2) simply returns 1, so you have
SUMPRODUCT(IF(MOD(1,2)=0,-1,1))

WITH CTRL + SHIFT + ENTER
ROW(1:2) will return the array {1,2}
So you get
SUMPRODUCT(IF(MOD({1,2},2)=0,-1,1))


Hope that helps.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,106
Messages
6,128,863
Members
449,473
Latest member
soumyahalder4

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top