snjpverma

Well-known Member
Joined
Oct 2, 2008
Messages
1,584
Office Version
  1. 365
Platform
  1. Windows
I want to calculate the total number of shortage. Please help me with a formula to do so. The excess should get adjusted with the forthcoming shortages. I am OK with using helper cells.

ABC
1DayTo be givenreceived
21st Day34
32nd Day32
43rd Day32
54th Day31
6
7 Total Shortage

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:64px;"><col style="width:97px;"><col style="width:64px;"></colgroup><tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi,

I'm probably misunderstanding your question:


Excel 2010
ABC
1DayTo be givenreceived
21st Day34
32nd Day32
43rd Day32
54th Day31
6
7Total Shortage3
Sheet18
Cell Formulas
RangeFormula
C7=ABS(SUM(C2:C5)-SUM(B2:B5))
 
Upvote 0
You're welcome, glad that's what you're looking for.
 
Upvote 0
Jkatw, your formula serves my purpose but I was curious to know why the formula gives me a wrong outcome in the scenario when the Total of "Received" is more than the total of "To be given".
For example, in below scenario. the shortage is showing as 3 instead of 0.
In actual, there an excess of 3 here. So the shortage should be zero.
.

ABC
DayTo be givenreceived
11st Day34
22nd Day35
33rd Day33
44th Day33
Total Shortage3

<tbody>
</tbody>
 
Last edited:
Upvote 0
You didn't specify what you wanted when there's no shortage.
If you just want 0 to show when there's no shortage, use this updated formula, take out the ABS function if you want the shortage to show as a negative number.
But if there is an "Overage", what do you want happened?


Excel 2010
ABC
1DayTo be givenreceived
21st Day34
32nd Day35
43rd Day33
54th Day33
6
7Total Shortage0
Sheet22
Cell Formulas
RangeFormula
C7=ABS(MIN(0,SUM(C2:C5)-SUM(B2:B5)))
 
Last edited:
Upvote 0
jkatw, the latest formula you gave doesn't work in the below scenario.
on the first and second day, there is a shortage of 1 each.. which means the total shortage should be 2 but it is giving zero as a result.


ABC
DayTo be givenreceived
1st Day32
2nd Day32
3rd Day34
4th Day34
Total Shortage0

<tbody>
</tbody>
 
Last edited:
Upvote 0
I thought you said in your OP "The excess should get adjusted with the forthcoming shortages", so the 3rd and 4th day overages would offset the shortages from 1st and 2nd day?
 
Upvote 0
Maybe you want this:


Excel 2010
ABCDE
1DayTo be givenreceivedreceivedreceived
21st Day3442
32nd Day3252
43rd Day3234
54th Day3134
6
7Total Shortage302
Sheet22
Cell Formulas
RangeFormula
C7=SUMPRODUCT(--(B2:B5>C2:C5))
 
Upvote 0
Ok, I Think I understand what you want now, so if and only if the Overage happens Prior to a Shortage, the overage would compensate for the shortage, but if the shortage happens before the overage, it is still counted, is that correct?

I've used a helper column if that's the case.


Excel 2010
ABCDEFGH
1DayTo be givenreceivedreceivedreceived
21st Day354221-1
32nd Day325213-2
43rd Day323403-1
54th Day3134-230
6
7Total Shortage202
Sheet22
Cell Formulas
RangeFormula
F2=C2-$B2+F1
F7=ABS(MIN(0,F2:F5))
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,900
Members
449,194
Latest member
JayEggleton

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