Forum Discussion
Erran Williams
Nov 23, 2017Copper Contributor
SUMIF Function for a period between two dates
Hi all,
I'm in a bit over my head with this at the moment..
I'm trying to keep track of pallet storage costs. To this end I would like to have cell D2 = sum of the cells in column C (2nd imag...
- Apr 28, 2021
Re: ``Very simple formula checked against a calculate and the answer is significantly incorrect``
You neglect to provide even a single example of the Excel result vs the calculator result.
But we might guess that you are making a very common mistake: when you enter values into the calculator, you enter them as they are displayed in Excel.
But the displayed values might be different from the actual values; and Excel uses the actual values in calculations.
For example, the formula in G7 is =B7*C7*H7*F3. B7 is 1, C7 is 77.81, H7 is 4, and F3 appears to be 39. And the result in G7 appears to be $12,093.90.
But if we enter 1*77.81*4*39 into a calculator, the result is $12,138.36. That is indeed very different.
The problem is: F3 only appears to be 39 because of the cell format. Its actual value is 38.8571428571429. And that is the value that Excel uses in the calculation.
To demonstrate, if we enter 1*77.81*4*38.85714 into the calculator (and display only 2 decimal places), the result appears to be $12,093.90 -- the same as G7.
And BTW, G7 only appears to be $12,093.90 because of the cell format. Its actual value is 12093.8971428571.
Only you can decide if and where to explicitly round Excel calculations. For example, you might write:
F3: =ROUND((E3-D3)/7, 0)
G7: =ROUND(B7*C7*H7*F3, 2)
(Arguably, rounding G7 is unnecessary if we round F3, at least for the example Excel file. But it is prudent to explicitly round calculations that involve decimal fractions for other reasons.)
Alternatively, you might choose to leave F3 unrounded for other purposes, but round its value when calculating G7. So, you might write:
F3: =(E3-D3)/7
G7: =ROUND(B7*C7*H7*ROUND(F3, 0), 2)
But in the final analysis, you might choose not to round at all, accepting the fact that the Excel calculation is more "accurate" (for some purposes) and different from the WYSIWYG calculations that you might enter on a calculator.
Aside.... There is no need to use DATEDIF(...,"d"); E3-D3 is simpler. And there is no need for the outer parentheses around the entire formula expression after the equal sign ("=").
-----
Caveat: Someone might suggest setting the option "Precision as displayed" to avoid the explicit rounding. I do not recommend that, for many reasons. But if you choose to experiment with PAD, be sure to make a copy of the Excel file first. Merely setting PAD might irreversibly change constants that you purposely display with less precision. Setting PAD affects all worksheets change in the entire Excel file. And PAD affects only the final value in a cell that is formatted as intended; for example, =IF(F3=39, TRUE) would still return FALSE(!).
Sakana
Dec 20, 2018Copper Contributor
Thanks for the reply. I had actually already seen your videos. They just aren't quite what I was looking for, but did give me some ideas on how to accomplish most of what I want. I don't need all the sales related stuff, just a way to keep track of items on hand from multiple sheets.
I do wonder though, you manually named some columns. If I'm using tables that is basically the same thing as you did but the headers of the tables columns are the named ranges now for each sheet?
Also, maybe you have a solution for this. At this point I feel my full vision isn't quite possible in the way I feel it should be. So as a step back is it possible to just combine all the data from all my tables into one giant list that stays dynamic. Meaning if I add to one of the other tables, the master list sheet also gets the updated entry? So far all the ways I've seen to combine tables they are static.
Sakana
Dec 20, 2018Copper Contributor
I had one other thought to ask.
Is there a function or series of functions that can look at a column and return how many of a duplicate entry there are. Or even better return the entry value and how many there are of it?
- tartrazeenMay 06, 2024Copper ContributorYou're genuinely my hero. Thank you so much for figuring this out and posting the answer!
It was a table for me, too. 🙂