Why is that when I call sum function over a defined name, the result is wrong?

toaruScar

New Member
Joined
Jun 22, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I'll first reproduce my problem here:

I have 3 tables:
Screenshot 2023-06-21 213201.png


The upper left one contains the raw score (RawScore), the upper right one contains some modifications we want to apply to the scores (ScoreMod). And the lower one is the total score (Total).

I calculated the Tom's "effective scores" for each day by adding the modifiers to the raw scores with the following formula:
Excel Formula:
=LET(
MyDate,FILTER(RawScore[Date],RawScore[Name]=Total[@Name]),
MyRawScore,FILTER(RawScore[Score],RawScore[Name]=Total[@Name]),
MyModifier, XLOOKUP(MyDate, FILTER(ScoreMod[Date], ScoreMod[Name]=Total[@Name],0),  FILTER(ScoreMod[Modifier], ScoreMod[Name]=Total[@Name],0), 0),
MyModifier+MyRawScore)

When I put this formula at D12, and it correctly calculates the effective scores.

Then I define a name with the above function, called it "EffectiveScore"
The problem is that when I try to calculate the Tom's total score, by having
Excel Formula:
=SUM(EffectiveScore)
At B12, the amount is not correct, it shows 500, instead of 480.

But if I replace the formula with
Excel Formula:
=SUM(MAP(EffectiveScore, LAMBDA(x, INT(x))))
,
It returns the correct result, 480.

Why do I have to wrap the formula with bunch of useless extra functions to get the right result?

This sample worksheet is available at Sum is incorrect.xlsx
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I don't have Excel 365, so unfortunately, I can't try it out myself. But, why not give SUMIF a shot?

Code:
=SUMIF(RawScore[Name],[@Name],RawScore[Score])+SUMIF(ScoreMod[Name],[@Name],ScoreMod[Modifier])
 
Upvote 0
I don't have Excel 365, so unfortunately, I can't try it out myself. But, why not give SUMIF a shot?

Code:
=SUMIF(RawScore[Name],[@Name],RawScore[Score])+SUMIF(ScoreMod[Name],[@Name],ScoreMod[Modifier])
Thanks for the quick reply, but the sum here is just a quick way to demonstrate the problem I'm having. I'd like to be able to use the "EffectiveScore" name at more places and also in more complicated use cases to make my actual worksheet easier to understand. This wired behavior caught me off guard. I want to understand what's going on here, so there'll be no more surprises in the future.
 
Upvote 0
Not sure what is going on, but you can use
Excel Formula:
=SUM(+EffectiveScore)
 
Upvote 0
Solution
Not sure what is going on, but you can use
Excel Formula:
=SUM(+EffectiveScore)
Wow, It works, but how? I don't even know one can use plus sign like this. I tried to find some documentation for this but can't find any, could you please explain what this plus sign does?
 
Upvote 0
It's often used to turn a range into an array, but as your formula returns an array I'm not sure why it makes a difference.
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,077
Members
449,094
Latest member
mystic19

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