How to add and subtract based on multiple conditions?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
This question is for an Inventory tracking system I am making in Google Sheets.
Just to be clear:
- Any incoming Items have a positive quantity
- Any outgoing Items have a negative quantity
The requirement is, when the closing stock is counted, the On-Hand quantity is put, which is a positive number. This positive number is what is currently available in stock.
Inversely, if the closing stock is put as a negative number, it means it is the amount consumed (negative number). Here, it will be subtracted from total previous stock.
The challenge is therefore to calculate this:
Stock for Item X = [Difference between its total qty & the closing (on-hand) qty] - [previous stock]
I Used SUMIFS to get the stock for each item. This doesn't take into account the date, as we need the current stock to be calculated, regardless of days.
Problem:
This works only till I add new incoming stock, after which the whole calculation goes for a toss. For example, if I add 10,000 on the 3rd day, the Inventory comes to -4300, when it should have been 15,700
See images for better understanding.
Before:
No new stock added on day 3 --> The sumifs seems fine.
After:
10,000 qty added on day 3 --> breaks the sumifs.
Let me know if you need any other information to understand.
Would appreciate any help..
Spent too much time already on this. Thanks.
P.S. - I hope I am posting on the right stack. Should I post this on webapps too?
worksheet-function google-spreadsheets
add a comment |
This question is for an Inventory tracking system I am making in Google Sheets.
Just to be clear:
- Any incoming Items have a positive quantity
- Any outgoing Items have a negative quantity
The requirement is, when the closing stock is counted, the On-Hand quantity is put, which is a positive number. This positive number is what is currently available in stock.
Inversely, if the closing stock is put as a negative number, it means it is the amount consumed (negative number). Here, it will be subtracted from total previous stock.
The challenge is therefore to calculate this:
Stock for Item X = [Difference between its total qty & the closing (on-hand) qty] - [previous stock]
I Used SUMIFS to get the stock for each item. This doesn't take into account the date, as we need the current stock to be calculated, regardless of days.
Problem:
This works only till I add new incoming stock, after which the whole calculation goes for a toss. For example, if I add 10,000 on the 3rd day, the Inventory comes to -4300, when it should have been 15,700
See images for better understanding.
Before:
No new stock added on day 3 --> The sumifs seems fine.
After:
10,000 qty added on day 3 --> breaks the sumifs.
Let me know if you need any other information to understand.
Would appreciate any help..
Spent too much time already on this. Thanks.
P.S. - I hope I am posting on the right stack. Should I post this on webapps too?
worksheet-function google-spreadsheets
It's a good idea to read the Wiki for the tags you select. BUT, don't cross-post. We're voting to get this question moved over to WebApps and once enough votes come in, it'll be moved automatically.
– music2myear
Jan 29 at 16:30
add a comment |
This question is for an Inventory tracking system I am making in Google Sheets.
Just to be clear:
- Any incoming Items have a positive quantity
- Any outgoing Items have a negative quantity
The requirement is, when the closing stock is counted, the On-Hand quantity is put, which is a positive number. This positive number is what is currently available in stock.
Inversely, if the closing stock is put as a negative number, it means it is the amount consumed (negative number). Here, it will be subtracted from total previous stock.
The challenge is therefore to calculate this:
Stock for Item X = [Difference between its total qty & the closing (on-hand) qty] - [previous stock]
I Used SUMIFS to get the stock for each item. This doesn't take into account the date, as we need the current stock to be calculated, regardless of days.
Problem:
This works only till I add new incoming stock, after which the whole calculation goes for a toss. For example, if I add 10,000 on the 3rd day, the Inventory comes to -4300, when it should have been 15,700
See images for better understanding.
Before:
No new stock added on day 3 --> The sumifs seems fine.
After:
10,000 qty added on day 3 --> breaks the sumifs.
Let me know if you need any other information to understand.
Would appreciate any help..
Spent too much time already on this. Thanks.
P.S. - I hope I am posting on the right stack. Should I post this on webapps too?
worksheet-function google-spreadsheets
This question is for an Inventory tracking system I am making in Google Sheets.
Just to be clear:
- Any incoming Items have a positive quantity
- Any outgoing Items have a negative quantity
The requirement is, when the closing stock is counted, the On-Hand quantity is put, which is a positive number. This positive number is what is currently available in stock.
Inversely, if the closing stock is put as a negative number, it means it is the amount consumed (negative number). Here, it will be subtracted from total previous stock.
The challenge is therefore to calculate this:
Stock for Item X = [Difference between its total qty & the closing (on-hand) qty] - [previous stock]
I Used SUMIFS to get the stock for each item. This doesn't take into account the date, as we need the current stock to be calculated, regardless of days.
Problem:
This works only till I add new incoming stock, after which the whole calculation goes for a toss. For example, if I add 10,000 on the 3rd day, the Inventory comes to -4300, when it should have been 15,700
See images for better understanding.
Before:
No new stock added on day 3 --> The sumifs seems fine.
After:
10,000 qty added on day 3 --> breaks the sumifs.
Let me know if you need any other information to understand.
Would appreciate any help..
Spent too much time already on this. Thanks.
P.S. - I hope I am posting on the right stack. Should I post this on webapps too?
worksheet-function google-spreadsheets
worksheet-function google-spreadsheets
edited Jan 28 at 10:09
fixer1234
19.4k145082
19.4k145082
asked Jan 28 at 10:08
Jeet ShahJeet Shah
11
11
It's a good idea to read the Wiki for the tags you select. BUT, don't cross-post. We're voting to get this question moved over to WebApps and once enough votes come in, it'll be moved automatically.
– music2myear
Jan 29 at 16:30
add a comment |
It's a good idea to read the Wiki for the tags you select. BUT, don't cross-post. We're voting to get this question moved over to WebApps and once enough votes come in, it'll be moved automatically.
– music2myear
Jan 29 at 16:30
It's a good idea to read the Wiki for the tags you select. BUT, don't cross-post. We're voting to get this question moved over to WebApps and once enough votes come in, it'll be moved automatically.
– music2myear
Jan 29 at 16:30
It's a good idea to read the Wiki for the tags you select. BUT, don't cross-post. We're voting to get this question moved over to WebApps and once enough votes come in, it'll be moved automatically.
– music2myear
Jan 29 at 16:30
add a comment |
1 Answer
1
active
oldest
votes
Jeet, welcome. Here are a few principles for Inventory management in Excel (and bank-account balance!) and debugging this question.
Separate your transactions from your running balance.
Use separate columns, not only for readability, but to help keep your formulas bug-free. In the example, it appears you're using SUMIFS to look for text cues ("Opening", "Closing", "Going") but this makes it impossible to validate a printout or screen dump. Use a separate column, like a ledger.
Never allow a negative number of Inventory.
Your inventory column should never go below zero, if your inventory is physical objects. Instead, prevent your transaction column from allowing more items to be subtracted than are available in inventory -- and require that more inventory be added before it is withdrawn.
There are a couple of ways to do this, but one way is to create an additional column for "backorder", "over-demanded", or "unfulfilled" inventory requests which are addressed before additional transactions.
You should do this even if your "inventory" consists of items that are easily available outside of your company, no matter how simple they are to get. (Even AA batteries available at a grocery-store next door which is open 24 hours per day).
Since you're modeling a physical process, you should not allow your spreadsheet to model something that's not possible. Model what's required to happen (in the example above, acquire the batteries next door, then send them out to a customer).
For debugging, build your "big formulas" from formulas from pieces that work.
There's a temptation to create big formulas on the first go. This makes them very hard to debug. It's far better to create small formulas (one clause at a time) that work -- test different cases on them, for example, positive transactions, negative transactions, transactions with zero balance, etc. -- and once you have everything working, consolidate them into big mega-formulas.
Your question did not provide the actual formulas you're using, so it's not possible to debug more specifically at this time. Finally, there is no Stack specific to spreadsheets, so you're right, it's not clear if this is a Super-user or Web-applications question. There should be a Spreadsheets stack.
Thanks for the explanation! I do have different columns for qty & running balance. The +/- numbers are just to indicate how much qty is coming/going. The inventory is updated based on these numbers, so inventory is always >0. Also, there is a way to indicate if there is not enough stock. Have tried to do parts of the formula (see sumifs table in images); but still have no clue where I am going wrong. I have no issues with the formulas themselves, so didn't post any. Its the logic / calculation where I am lost. 👍 for Spreadsheets Stack!
– Jeet Shah
Jan 29 at 4:37
Jeet, based on the screen-dumps (images) you posted, your SUMIFS statement is not "capturing" (including) cell R10. It is not possible to diagnose further without a copy of the spreadsheet, or knowing what formula you are using. (Your objective -- track inventory -- can be done without any SUMIFS formulas at all, using a stepwise approach such as you'd use for a checkbook-balancing or bank-account keeping spreadsheet.)
– whiskeychief
Jan 30 at 10:56
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1399184%2fhow-to-add-and-subtract-based-on-multiple-conditions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Jeet, welcome. Here are a few principles for Inventory management in Excel (and bank-account balance!) and debugging this question.
Separate your transactions from your running balance.
Use separate columns, not only for readability, but to help keep your formulas bug-free. In the example, it appears you're using SUMIFS to look for text cues ("Opening", "Closing", "Going") but this makes it impossible to validate a printout or screen dump. Use a separate column, like a ledger.
Never allow a negative number of Inventory.
Your inventory column should never go below zero, if your inventory is physical objects. Instead, prevent your transaction column from allowing more items to be subtracted than are available in inventory -- and require that more inventory be added before it is withdrawn.
There are a couple of ways to do this, but one way is to create an additional column for "backorder", "over-demanded", or "unfulfilled" inventory requests which are addressed before additional transactions.
You should do this even if your "inventory" consists of items that are easily available outside of your company, no matter how simple they are to get. (Even AA batteries available at a grocery-store next door which is open 24 hours per day).
Since you're modeling a physical process, you should not allow your spreadsheet to model something that's not possible. Model what's required to happen (in the example above, acquire the batteries next door, then send them out to a customer).
For debugging, build your "big formulas" from formulas from pieces that work.
There's a temptation to create big formulas on the first go. This makes them very hard to debug. It's far better to create small formulas (one clause at a time) that work -- test different cases on them, for example, positive transactions, negative transactions, transactions with zero balance, etc. -- and once you have everything working, consolidate them into big mega-formulas.
Your question did not provide the actual formulas you're using, so it's not possible to debug more specifically at this time. Finally, there is no Stack specific to spreadsheets, so you're right, it's not clear if this is a Super-user or Web-applications question. There should be a Spreadsheets stack.
Thanks for the explanation! I do have different columns for qty & running balance. The +/- numbers are just to indicate how much qty is coming/going. The inventory is updated based on these numbers, so inventory is always >0. Also, there is a way to indicate if there is not enough stock. Have tried to do parts of the formula (see sumifs table in images); but still have no clue where I am going wrong. I have no issues with the formulas themselves, so didn't post any. Its the logic / calculation where I am lost. 👍 for Spreadsheets Stack!
– Jeet Shah
Jan 29 at 4:37
Jeet, based on the screen-dumps (images) you posted, your SUMIFS statement is not "capturing" (including) cell R10. It is not possible to diagnose further without a copy of the spreadsheet, or knowing what formula you are using. (Your objective -- track inventory -- can be done without any SUMIFS formulas at all, using a stepwise approach such as you'd use for a checkbook-balancing or bank-account keeping spreadsheet.)
– whiskeychief
Jan 30 at 10:56
add a comment |
Jeet, welcome. Here are a few principles for Inventory management in Excel (and bank-account balance!) and debugging this question.
Separate your transactions from your running balance.
Use separate columns, not only for readability, but to help keep your formulas bug-free. In the example, it appears you're using SUMIFS to look for text cues ("Opening", "Closing", "Going") but this makes it impossible to validate a printout or screen dump. Use a separate column, like a ledger.
Never allow a negative number of Inventory.
Your inventory column should never go below zero, if your inventory is physical objects. Instead, prevent your transaction column from allowing more items to be subtracted than are available in inventory -- and require that more inventory be added before it is withdrawn.
There are a couple of ways to do this, but one way is to create an additional column for "backorder", "over-demanded", or "unfulfilled" inventory requests which are addressed before additional transactions.
You should do this even if your "inventory" consists of items that are easily available outside of your company, no matter how simple they are to get. (Even AA batteries available at a grocery-store next door which is open 24 hours per day).
Since you're modeling a physical process, you should not allow your spreadsheet to model something that's not possible. Model what's required to happen (in the example above, acquire the batteries next door, then send them out to a customer).
For debugging, build your "big formulas" from formulas from pieces that work.
There's a temptation to create big formulas on the first go. This makes them very hard to debug. It's far better to create small formulas (one clause at a time) that work -- test different cases on them, for example, positive transactions, negative transactions, transactions with zero balance, etc. -- and once you have everything working, consolidate them into big mega-formulas.
Your question did not provide the actual formulas you're using, so it's not possible to debug more specifically at this time. Finally, there is no Stack specific to spreadsheets, so you're right, it's not clear if this is a Super-user or Web-applications question. There should be a Spreadsheets stack.
Thanks for the explanation! I do have different columns for qty & running balance. The +/- numbers are just to indicate how much qty is coming/going. The inventory is updated based on these numbers, so inventory is always >0. Also, there is a way to indicate if there is not enough stock. Have tried to do parts of the formula (see sumifs table in images); but still have no clue where I am going wrong. I have no issues with the formulas themselves, so didn't post any. Its the logic / calculation where I am lost. 👍 for Spreadsheets Stack!
– Jeet Shah
Jan 29 at 4:37
Jeet, based on the screen-dumps (images) you posted, your SUMIFS statement is not "capturing" (including) cell R10. It is not possible to diagnose further without a copy of the spreadsheet, or knowing what formula you are using. (Your objective -- track inventory -- can be done without any SUMIFS formulas at all, using a stepwise approach such as you'd use for a checkbook-balancing or bank-account keeping spreadsheet.)
– whiskeychief
Jan 30 at 10:56
add a comment |
Jeet, welcome. Here are a few principles for Inventory management in Excel (and bank-account balance!) and debugging this question.
Separate your transactions from your running balance.
Use separate columns, not only for readability, but to help keep your formulas bug-free. In the example, it appears you're using SUMIFS to look for text cues ("Opening", "Closing", "Going") but this makes it impossible to validate a printout or screen dump. Use a separate column, like a ledger.
Never allow a negative number of Inventory.
Your inventory column should never go below zero, if your inventory is physical objects. Instead, prevent your transaction column from allowing more items to be subtracted than are available in inventory -- and require that more inventory be added before it is withdrawn.
There are a couple of ways to do this, but one way is to create an additional column for "backorder", "over-demanded", or "unfulfilled" inventory requests which are addressed before additional transactions.
You should do this even if your "inventory" consists of items that are easily available outside of your company, no matter how simple they are to get. (Even AA batteries available at a grocery-store next door which is open 24 hours per day).
Since you're modeling a physical process, you should not allow your spreadsheet to model something that's not possible. Model what's required to happen (in the example above, acquire the batteries next door, then send them out to a customer).
For debugging, build your "big formulas" from formulas from pieces that work.
There's a temptation to create big formulas on the first go. This makes them very hard to debug. It's far better to create small formulas (one clause at a time) that work -- test different cases on them, for example, positive transactions, negative transactions, transactions with zero balance, etc. -- and once you have everything working, consolidate them into big mega-formulas.
Your question did not provide the actual formulas you're using, so it's not possible to debug more specifically at this time. Finally, there is no Stack specific to spreadsheets, so you're right, it's not clear if this is a Super-user or Web-applications question. There should be a Spreadsheets stack.
Jeet, welcome. Here are a few principles for Inventory management in Excel (and bank-account balance!) and debugging this question.
Separate your transactions from your running balance.
Use separate columns, not only for readability, but to help keep your formulas bug-free. In the example, it appears you're using SUMIFS to look for text cues ("Opening", "Closing", "Going") but this makes it impossible to validate a printout or screen dump. Use a separate column, like a ledger.
Never allow a negative number of Inventory.
Your inventory column should never go below zero, if your inventory is physical objects. Instead, prevent your transaction column from allowing more items to be subtracted than are available in inventory -- and require that more inventory be added before it is withdrawn.
There are a couple of ways to do this, but one way is to create an additional column for "backorder", "over-demanded", or "unfulfilled" inventory requests which are addressed before additional transactions.
You should do this even if your "inventory" consists of items that are easily available outside of your company, no matter how simple they are to get. (Even AA batteries available at a grocery-store next door which is open 24 hours per day).
Since you're modeling a physical process, you should not allow your spreadsheet to model something that's not possible. Model what's required to happen (in the example above, acquire the batteries next door, then send them out to a customer).
For debugging, build your "big formulas" from formulas from pieces that work.
There's a temptation to create big formulas on the first go. This makes them very hard to debug. It's far better to create small formulas (one clause at a time) that work -- test different cases on them, for example, positive transactions, negative transactions, transactions with zero balance, etc. -- and once you have everything working, consolidate them into big mega-formulas.
Your question did not provide the actual formulas you're using, so it's not possible to debug more specifically at this time. Finally, there is no Stack specific to spreadsheets, so you're right, it's not clear if this is a Super-user or Web-applications question. There should be a Spreadsheets stack.
answered Jan 28 at 11:15
whiskeychiefwhiskeychief
1607
1607
Thanks for the explanation! I do have different columns for qty & running balance. The +/- numbers are just to indicate how much qty is coming/going. The inventory is updated based on these numbers, so inventory is always >0. Also, there is a way to indicate if there is not enough stock. Have tried to do parts of the formula (see sumifs table in images); but still have no clue where I am going wrong. I have no issues with the formulas themselves, so didn't post any. Its the logic / calculation where I am lost. 👍 for Spreadsheets Stack!
– Jeet Shah
Jan 29 at 4:37
Jeet, based on the screen-dumps (images) you posted, your SUMIFS statement is not "capturing" (including) cell R10. It is not possible to diagnose further without a copy of the spreadsheet, or knowing what formula you are using. (Your objective -- track inventory -- can be done without any SUMIFS formulas at all, using a stepwise approach such as you'd use for a checkbook-balancing or bank-account keeping spreadsheet.)
– whiskeychief
Jan 30 at 10:56
add a comment |
Thanks for the explanation! I do have different columns for qty & running balance. The +/- numbers are just to indicate how much qty is coming/going. The inventory is updated based on these numbers, so inventory is always >0. Also, there is a way to indicate if there is not enough stock. Have tried to do parts of the formula (see sumifs table in images); but still have no clue where I am going wrong. I have no issues with the formulas themselves, so didn't post any. Its the logic / calculation where I am lost. 👍 for Spreadsheets Stack!
– Jeet Shah
Jan 29 at 4:37
Jeet, based on the screen-dumps (images) you posted, your SUMIFS statement is not "capturing" (including) cell R10. It is not possible to diagnose further without a copy of the spreadsheet, or knowing what formula you are using. (Your objective -- track inventory -- can be done without any SUMIFS formulas at all, using a stepwise approach such as you'd use for a checkbook-balancing or bank-account keeping spreadsheet.)
– whiskeychief
Jan 30 at 10:56
Thanks for the explanation! I do have different columns for qty & running balance. The +/- numbers are just to indicate how much qty is coming/going. The inventory is updated based on these numbers, so inventory is always >0. Also, there is a way to indicate if there is not enough stock. Have tried to do parts of the formula (see sumifs table in images); but still have no clue where I am going wrong. I have no issues with the formulas themselves, so didn't post any. Its the logic / calculation where I am lost. 👍 for Spreadsheets Stack!
– Jeet Shah
Jan 29 at 4:37
Thanks for the explanation! I do have different columns for qty & running balance. The +/- numbers are just to indicate how much qty is coming/going. The inventory is updated based on these numbers, so inventory is always >0. Also, there is a way to indicate if there is not enough stock. Have tried to do parts of the formula (see sumifs table in images); but still have no clue where I am going wrong. I have no issues with the formulas themselves, so didn't post any. Its the logic / calculation where I am lost. 👍 for Spreadsheets Stack!
– Jeet Shah
Jan 29 at 4:37
Jeet, based on the screen-dumps (images) you posted, your SUMIFS statement is not "capturing" (including) cell R10. It is not possible to diagnose further without a copy of the spreadsheet, or knowing what formula you are using. (Your objective -- track inventory -- can be done without any SUMIFS formulas at all, using a stepwise approach such as you'd use for a checkbook-balancing or bank-account keeping spreadsheet.)
– whiskeychief
Jan 30 at 10:56
Jeet, based on the screen-dumps (images) you posted, your SUMIFS statement is not "capturing" (including) cell R10. It is not possible to diagnose further without a copy of the spreadsheet, or knowing what formula you are using. (Your objective -- track inventory -- can be done without any SUMIFS formulas at all, using a stepwise approach such as you'd use for a checkbook-balancing or bank-account keeping spreadsheet.)
– whiskeychief
Jan 30 at 10:56
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1399184%2fhow-to-add-and-subtract-based-on-multiple-conditions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It's a good idea to read the Wiki for the tags you select. BUT, don't cross-post. We're voting to get this question moved over to WebApps and once enough votes come in, it'll be moved automatically.
– music2myear
Jan 29 at 16:30