Adding or Subtracting based on 3 variables











up vote
-1
down vote

favorite












This may be simple but I'm new to formulae in Excel.



I've got two sets of data that both have Dates in one sheet. One set has repeated dates for every Type and every State because it's a cumulative summed frame which looks like:



Date          State     Type      Value 1
2010-01-01 AK NUC 10
2010-02-01 AK NUC 10
2010-03-01 AK NUC 10
.
.
2010-01-01 CO NUC 2
2010-02-01 CO NUC 2
.
.
2010-01-01 AK WND 20
2010-02-01 AK WND 21
.
.
2018-08-01 .......


What I need to do is take a second set and add based off the 'Operating Date', to each 'Type' and 'State' and then subtract based off the 'Retirement Date' all with respect to the original 'Date'. The second set looks like:



Operating Date   Retirement Date   Type    State       Value 2
2010-02-01 2010-04-01 NUC AK 1
2011-02-01 2014-02-01 NUC AK 2
2011-03-01 2016-03-01 NUC AK 10
.
.

.
2018-08-01 .......


My logic for the example on AK the output would add and subtract like:



if AK(Date) == AK(Operating Date):
AK(Value, Date) = AK(Value, Date) + AK(Value, Operating Date)

elif AK(Date) == AK(Retirement Date):
AK(Value, Date) = AK(Value, Date) - AK(Value, Retirement Date)
else:
continue


And the actual output data (just for AK 'NUC') would be:



Date          State     Type      Value
2010-01-01 AK NUC 10
2010-02-01 AK NUC 11
2010-03-01 AK NUC 11
2010-04-01 AK NUC 10
.
.
2011-01-01 AK NUC 10
2011-02-01 AK NUC 12
2011-03-01 AK NUC 22
2011-04-01 AK NUC 22
.
.
2016-01-01 AK NUC 22
2010-02-01 AK NUC 22
2010-03-01 AK NUC 12
2010-04-01 AK NUC 12
.
.


How can I go about doing this type of operation in Excel?










share|improve this question




















  • 2




    I'm sorry, but I've been staring at this for five minutes, and I just don't get it.   Can you show step by step how you get some of the results?   Please do not respond in comments; edit your question to make it clearer and more complete.
    – Scott
    Nov 30 at 2:05










  • Basically it's just saying that it will add the value on the Operating Date and then subtract it on the Retirement Date. So you see on 2010-02-01 the first Operating Date for AK in type NUC is of Value 1 so it is added on the first set as 10+1 = 11 but then the Retirement Date of that same Value is on 2010-04-01 so then on that date it is removed as 11-1 = 10.
    – HelloToEarth
    Nov 30 at 2:15










  • Please, edit your question when adding info.
    – cybernetic.nomad
    Nov 30 at 12:42















up vote
-1
down vote

favorite












This may be simple but I'm new to formulae in Excel.



I've got two sets of data that both have Dates in one sheet. One set has repeated dates for every Type and every State because it's a cumulative summed frame which looks like:



Date          State     Type      Value 1
2010-01-01 AK NUC 10
2010-02-01 AK NUC 10
2010-03-01 AK NUC 10
.
.
2010-01-01 CO NUC 2
2010-02-01 CO NUC 2
.
.
2010-01-01 AK WND 20
2010-02-01 AK WND 21
.
.
2018-08-01 .......


What I need to do is take a second set and add based off the 'Operating Date', to each 'Type' and 'State' and then subtract based off the 'Retirement Date' all with respect to the original 'Date'. The second set looks like:



Operating Date   Retirement Date   Type    State       Value 2
2010-02-01 2010-04-01 NUC AK 1
2011-02-01 2014-02-01 NUC AK 2
2011-03-01 2016-03-01 NUC AK 10
.
.

.
2018-08-01 .......


My logic for the example on AK the output would add and subtract like:



if AK(Date) == AK(Operating Date):
AK(Value, Date) = AK(Value, Date) + AK(Value, Operating Date)

elif AK(Date) == AK(Retirement Date):
AK(Value, Date) = AK(Value, Date) - AK(Value, Retirement Date)
else:
continue


And the actual output data (just for AK 'NUC') would be:



Date          State     Type      Value
2010-01-01 AK NUC 10
2010-02-01 AK NUC 11
2010-03-01 AK NUC 11
2010-04-01 AK NUC 10
.
.
2011-01-01 AK NUC 10
2011-02-01 AK NUC 12
2011-03-01 AK NUC 22
2011-04-01 AK NUC 22
.
.
2016-01-01 AK NUC 22
2010-02-01 AK NUC 22
2010-03-01 AK NUC 12
2010-04-01 AK NUC 12
.
.


How can I go about doing this type of operation in Excel?










share|improve this question




















  • 2




    I'm sorry, but I've been staring at this for five minutes, and I just don't get it.   Can you show step by step how you get some of the results?   Please do not respond in comments; edit your question to make it clearer and more complete.
    – Scott
    Nov 30 at 2:05










  • Basically it's just saying that it will add the value on the Operating Date and then subtract it on the Retirement Date. So you see on 2010-02-01 the first Operating Date for AK in type NUC is of Value 1 so it is added on the first set as 10+1 = 11 but then the Retirement Date of that same Value is on 2010-04-01 so then on that date it is removed as 11-1 = 10.
    – HelloToEarth
    Nov 30 at 2:15










  • Please, edit your question when adding info.
    – cybernetic.nomad
    Nov 30 at 12:42













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











This may be simple but I'm new to formulae in Excel.



I've got two sets of data that both have Dates in one sheet. One set has repeated dates for every Type and every State because it's a cumulative summed frame which looks like:



Date          State     Type      Value 1
2010-01-01 AK NUC 10
2010-02-01 AK NUC 10
2010-03-01 AK NUC 10
.
.
2010-01-01 CO NUC 2
2010-02-01 CO NUC 2
.
.
2010-01-01 AK WND 20
2010-02-01 AK WND 21
.
.
2018-08-01 .......


What I need to do is take a second set and add based off the 'Operating Date', to each 'Type' and 'State' and then subtract based off the 'Retirement Date' all with respect to the original 'Date'. The second set looks like:



Operating Date   Retirement Date   Type    State       Value 2
2010-02-01 2010-04-01 NUC AK 1
2011-02-01 2014-02-01 NUC AK 2
2011-03-01 2016-03-01 NUC AK 10
.
.

.
2018-08-01 .......


My logic for the example on AK the output would add and subtract like:



if AK(Date) == AK(Operating Date):
AK(Value, Date) = AK(Value, Date) + AK(Value, Operating Date)

elif AK(Date) == AK(Retirement Date):
AK(Value, Date) = AK(Value, Date) - AK(Value, Retirement Date)
else:
continue


And the actual output data (just for AK 'NUC') would be:



Date          State     Type      Value
2010-01-01 AK NUC 10
2010-02-01 AK NUC 11
2010-03-01 AK NUC 11
2010-04-01 AK NUC 10
.
.
2011-01-01 AK NUC 10
2011-02-01 AK NUC 12
2011-03-01 AK NUC 22
2011-04-01 AK NUC 22
.
.
2016-01-01 AK NUC 22
2010-02-01 AK NUC 22
2010-03-01 AK NUC 12
2010-04-01 AK NUC 12
.
.


How can I go about doing this type of operation in Excel?










share|improve this question















This may be simple but I'm new to formulae in Excel.



I've got two sets of data that both have Dates in one sheet. One set has repeated dates for every Type and every State because it's a cumulative summed frame which looks like:



Date          State     Type      Value 1
2010-01-01 AK NUC 10
2010-02-01 AK NUC 10
2010-03-01 AK NUC 10
.
.
2010-01-01 CO NUC 2
2010-02-01 CO NUC 2
.
.
2010-01-01 AK WND 20
2010-02-01 AK WND 21
.
.
2018-08-01 .......


What I need to do is take a second set and add based off the 'Operating Date', to each 'Type' and 'State' and then subtract based off the 'Retirement Date' all with respect to the original 'Date'. The second set looks like:



Operating Date   Retirement Date   Type    State       Value 2
2010-02-01 2010-04-01 NUC AK 1
2011-02-01 2014-02-01 NUC AK 2
2011-03-01 2016-03-01 NUC AK 10
.
.

.
2018-08-01 .......


My logic for the example on AK the output would add and subtract like:



if AK(Date) == AK(Operating Date):
AK(Value, Date) = AK(Value, Date) + AK(Value, Operating Date)

elif AK(Date) == AK(Retirement Date):
AK(Value, Date) = AK(Value, Date) - AK(Value, Retirement Date)
else:
continue


And the actual output data (just for AK 'NUC') would be:



Date          State     Type      Value
2010-01-01 AK NUC 10
2010-02-01 AK NUC 11
2010-03-01 AK NUC 11
2010-04-01 AK NUC 10
.
.
2011-01-01 AK NUC 10
2011-02-01 AK NUC 12
2011-03-01 AK NUC 22
2011-04-01 AK NUC 22
.
.
2016-01-01 AK NUC 22
2010-02-01 AK NUC 22
2010-03-01 AK NUC 12
2010-04-01 AK NUC 12
.
.


How can I go about doing this type of operation in Excel?







microsoft-excel worksheet-function microsoft-excel-2010






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 30 at 2:16

























asked Nov 30 at 1:19









HelloToEarth

991




991








  • 2




    I'm sorry, but I've been staring at this for five minutes, and I just don't get it.   Can you show step by step how you get some of the results?   Please do not respond in comments; edit your question to make it clearer and more complete.
    – Scott
    Nov 30 at 2:05










  • Basically it's just saying that it will add the value on the Operating Date and then subtract it on the Retirement Date. So you see on 2010-02-01 the first Operating Date for AK in type NUC is of Value 1 so it is added on the first set as 10+1 = 11 but then the Retirement Date of that same Value is on 2010-04-01 so then on that date it is removed as 11-1 = 10.
    – HelloToEarth
    Nov 30 at 2:15










  • Please, edit your question when adding info.
    – cybernetic.nomad
    Nov 30 at 12:42














  • 2




    I'm sorry, but I've been staring at this for five minutes, and I just don't get it.   Can you show step by step how you get some of the results?   Please do not respond in comments; edit your question to make it clearer and more complete.
    – Scott
    Nov 30 at 2:05










  • Basically it's just saying that it will add the value on the Operating Date and then subtract it on the Retirement Date. So you see on 2010-02-01 the first Operating Date for AK in type NUC is of Value 1 so it is added on the first set as 10+1 = 11 but then the Retirement Date of that same Value is on 2010-04-01 so then on that date it is removed as 11-1 = 10.
    – HelloToEarth
    Nov 30 at 2:15










  • Please, edit your question when adding info.
    – cybernetic.nomad
    Nov 30 at 12:42








2




2




I'm sorry, but I've been staring at this for five minutes, and I just don't get it.   Can you show step by step how you get some of the results?   Please do not respond in comments; edit your question to make it clearer and more complete.
– Scott
Nov 30 at 2:05




I'm sorry, but I've been staring at this for five minutes, and I just don't get it.   Can you show step by step how you get some of the results?   Please do not respond in comments; edit your question to make it clearer and more complete.
– Scott
Nov 30 at 2:05












Basically it's just saying that it will add the value on the Operating Date and then subtract it on the Retirement Date. So you see on 2010-02-01 the first Operating Date for AK in type NUC is of Value 1 so it is added on the first set as 10+1 = 11 but then the Retirement Date of that same Value is on 2010-04-01 so then on that date it is removed as 11-1 = 10.
– HelloToEarth
Nov 30 at 2:15




Basically it's just saying that it will add the value on the Operating Date and then subtract it on the Retirement Date. So you see on 2010-02-01 the first Operating Date for AK in type NUC is of Value 1 so it is added on the first set as 10+1 = 11 but then the Retirement Date of that same Value is on 2010-04-01 so then on that date it is removed as 11-1 = 10.
– HelloToEarth
Nov 30 at 2:15












Please, edit your question when adding info.
– cybernetic.nomad
Nov 30 at 12:42




Please, edit your question when adding info.
– cybernetic.nomad
Nov 30 at 12:42















active

oldest

votes











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',
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379617%2fadding-or-subtracting-based-on-3-variables%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379617%2fadding-or-subtracting-based-on-3-variables%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]