+ Reply to Thread
Results 1 to 15 of 15

Cumulative SUM and IF

  1. #1
    Registered User
    Join Date
    12-23-2012
    Location
    Banja Luka, B&H
    MS-Off Ver
    MS Office Excel 365
    Posts
    20

    Cumulative SUM and IF

    Hi,

    I have 4 example of tables. There are green columns, that show desired output per very example. Don't be confused, new_OQ (desired output) is calculated manually by me. Instead, there are should be formulas.

    I need to create one common formula that would be useful in all examples.

    There is 2 kind of quantities, one is order quantity and second one is preorder quantity. If preorder quantity shows in row, then logic has to decide which quantity is the correct one. If the preorder quantity is greater then order quantity, then logic picks preorder quantity until it is all "used" by order quantity.

    When you look at examples it will be much clearer. If you need any additional info please ask.

    Thanks in advance.

    Milan B.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    12-23-2012
    Location
    Banja Luka, B&H
    MS-Off Ver
    MS Office Excel 365
    Posts
    20

    Re: Cumulative SUM and IF

    Hi,

    Just kind reminder about this issue. I would be thankful if someone can give me a advice how to do it.

    Milan B.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Cumulative SUM and IF

    It's not clear to me how you are deriving the results, even though I've read your description. I think you might need to explain one series in more detail.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    12-23-2012
    Location
    Banja Luka, B&H
    MS-Off Ver
    MS Office Excel 365
    Posts
    20

    Re: Cumulative SUM and IF

    Thanks for reply.

    Imagine that in order_qty column are standard orders which are placed once per week for one specific item. But, sometimes it can happen that we make special (preo_qty) orders, which can happen in any week. Related to order_qty, we are talking about forecasted values not the real ones. Also, preo_qty are scheduled for future. The purpose of this tool is to somehow exclude "double orders". If preo_qty exists, then we must "use" all quantity of preo_qty before returning to weekly orders (order_qty). NOTICE: do not be confused with repeated values in preo_qty. The first value of preo_qty counts only. This is only how ERP exports data. It would be harder to recode ERP then to make excel table for help.

    For example 1.

    Row = 4; order_qty is 5, and preo_qty is empty. In such case we always use order_qty value.
    Row = 5; order_qty is 5, and preo_qty is empty. In such case we always use order_qty value.
    Row = 6; order_qty is 0, and preo_qty is 20. Because 20 > 0, we are now starting to use this value, until is completely used per weekly orders. new_OQ = 20.
    Row = 7; order_qty is 5, and preo_qty is used. 20 - 5 = 15. preo_qty is now 15 and it is not needed to place additional weekly order. new_OQ = 0.
    Row = 8; order_qty is 0, and preo_qty is used. 20 - 5 = 15. preo_qty is now 15 and it is not needed to place additional weekly order. new_OQ = 0.
    Row = 9; order_qty is 5, and preo_qty is used. 20 - 10 = 10. preo_qty is now 10 and it is not needed to place additional weekly order. new_OQ = 0.
    Row = 10; order_qty is 5, and preo_qty is used. 20 - 15 = 5. preo_qty is now 5 and it is not needed to place additional weekly order. new_OQ = 0.
    Row = 11; order_qty is 5, and preo_qty is used. 20 - 20 = 0. All preo_qty of 20 pieces is used. From down below we are starting to use normal order_qty, until new preo_qty pops put.
    Row = 12; order_qty is 0, and preo_qty is used. In such case we always use order_qty value.
    Row = 13; order_qty is 5, and preo_qty is used. In such case we always use order_qty value.
    Row = 14; order_qty is 0, and preo_qty is used. In such case we always use order_qty value.
    Row = 15; order_qty is 5, and preo_qty is used. In such case we always use order_qty value.
    Row = 16; order_qty is 0, and preo_qty is used. In such case we always use order_qty value.
    Row = 17; order_qty is 5, and preo_qty is used. In such case we always use order_qty value.
    Row = 18; order_qty is 5, and preo_qty is used. In such case we always use order_qty value.


    Sorry, it is hard to explain. I hope you will have motivation to help me until the end solution. And I will provide you necessary inputs.

    Simply speaking, logic should consider order_qty until the preo_qty shows. If the preo_qty is greater then order_qty, then start using preo_qty until its value is completely used by cumulative order_qty (starting from row in which preor_qty firstly showed).

    Milan B.
    Last edited by LemitoSanchez; 07-07-2021 at 06:26 AM.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Cumulative SUM and IF

    I had to resort to VBA to get a result but I am sure there is formula solution. I changed the "input" so that entries in "preo_qty" only appear once for each unique value.

    The VBA runs through all 4 examples and if are OK with Using VBA I can modify it to fit your actual data sheet,

    VBA use "Sheet1 (2)". Results in columns headed "UDF"

    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-23-2012
    Location
    Banja Luka, B&H
    MS-Off Ver
    MS Office Excel 365
    Posts
    20

    Re: Cumulative SUM and IF

    Thank you!

    Would be to hard to somehow translate this VBA into formulas? It is not required for formula to go into one cell, it can be spread in more columns for simplicity and better logic understanding.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Cumulative SUM and IF

    I tried various formula approaches with little success. I will see if a I can translate the VBA into a formula solution which as you suggest probably requires multiple "helper" columns

  8. #8
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,057

    Re: Cumulative SUM and IF

    Why is row 12 in Example 1, new_QQ is not 20? You should probably extend your example further down to show when you are using the preo_qty again.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Cumulative SUM and IF

    @josephteh
    Look at file in Post #1 as I amended the file (post #5) to suit the VBA solution.

  10. #10
    Registered User
    Join Date
    12-23-2012
    Location
    Banja Luka, B&H
    MS-Off Ver
    MS Office Excel 365
    Posts
    20

    Re: Cumulative SUM and IF

    Did you had any progress with formula version of file?

  11. #11
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Cumulative SUM and IF

    Quote Originally Posted by LemitoSanchez View Post
    Did you had any progress with formula version of file?
    Same question with josephteh in #8. Why D12 was expected to be 0?
    Quang PT

  12. #12
    Registered User
    Join Date
    12-23-2012
    Location
    Banja Luka, B&H
    MS-Off Ver
    MS Office Excel 365
    Posts
    20

    Re: Cumulative SUM and IF

    Logic is explained in Post 4. Preo_qty of 20 pieces is "depleted" by regular weekly orders (order_qty; cumulative 20). Therefor expected value is 0.

    The moment when preor_qty appers, we are starting to decrese preor_qty by order_qty (cumulativly), until it reaches 0 as in example above, or new different preor_qty value appears.

    It is tricky, but macro works when I tested it. Unfortunatelly, preffered option is by formulas.

  13. #13
    Registered User
    Join Date
    12-23-2012
    Location
    Banja Luka, B&H
    MS-Off Ver
    MS Office Excel 365
    Posts
    20

    Re: Cumulative SUM and IF

    Hello, I tried to make some formulas, it is "dirty" version but it does the job. I only have one issue so far and that is related to conditional running total. Not sure how to start doing running SUM after some condition is fulfilled. I marked it with orange color.

    Sheet "example_1".
    Attached Files Attached Files

  14. #14
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,556

    Re: Cumulative SUM and IF

    Not sure how to start doing running SUM after some condition is fulfilled.
    What is the condition?
    It might also help if you would manually place the correct values in column H so that we can compare those to the output of our proposed formulas/code.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Cumulative SUM and IF

    Is this it?

    =IF(C4="","",C4-SUM(B$4:B4))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Cumulative sum formula
    By dtrom26 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-10-2019, 11:10 AM
  2. [SOLVED] Cumulative sum
    By Median in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-26-2018, 10:32 AM
  3. Cumulative value
    By Anuru in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-10-2016, 03:51 AM
  4. [SOLVED] Cumulative Sum...is it possible?
    By excelfoum123 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-19-2014, 12:57 PM
  5. Formulas for cumulative value and cumulative %
    By Brotein in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-28-2013, 07:19 PM
  6. Top cumulative %
    By sttrader in forum Excel General
    Replies: 7
    Last Post: 12-18-2011, 03:07 PM
  7. cumulative sum
    By johngav in forum Excel General
    Replies: 6
    Last Post: 10-06-2008, 03:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1