Sum columnA/sum columnB, if row Has data up to columnB

  • I don't know if it is wrong to post too many questions in a day or not, but this has been such a great help I thought I would try to clean up some of my own formulas that look hideous and take lots of time to edit. I didn't know how to title this but basically my customers are billed monthly. The months are laid out across Row 12. Below the months is the amount the customer has paid on their bill. The customer has a set bill located in Column M starting at 13-150. The bill amounts are different for each customer. I want to know for each month what our percentage of paid vs. billed was. This of course then includes over customers who started later on or earlier and I want to only include those who have paid a bill at least once and have a number in column M >0. I will attach the sheet so you can see, and I do have a very lengthy formula that I believe works but it took about 2 hours just to do each formula. The formula is inserted in "paid/billed" row 5.

    Here is the formula:

    It's a mess!

    Thank you for your help.

  • Re: Sum columnA/sum columnB, if row Has data up to columnB

    Hi Cya,

    if I saw that formula in a workbook that was handed to me, I would want to repeatedly hit myself in the face with a rusty blunt object. And probably try and find the author (with said tool still in my hand)

    I think the easiest thing you can do here is create another sheet that sits behind the front sheet. You can just copy and paste the sheet if you want. However instead of the actual amounts paid against each customer, the cells for each months can sum up the cumulative amounts to Jan/Feb/Mar based on the amounts paid for each month on the front sheet.

    You can then insert a column or rows on that sheet to do a test to see if the sum is greater/less than column M.

    You can then use THIS number in your formula on the front sheet.

    First thing is to create another sheet with the cumulative numbers on to avoid having them in the formula. Once you do this you'll be able to set up the other calcs easily

  • Re: Sum columnA/sum columnB, if row Has data up to columnB

    I am sorry call me dumb, but I am confused. I should total the months and put them against what should paid to see if it is the same.

    I am trying to get an individual number for each customer based on amount they paid per month from their starting date to the current month and divided by the total months in the calculation. So that I have a finished average they have paid per month overall. This would need to exclude the two columns in between each year where I have some other calculations. I am not sure if what you are suggesting will help me get to that end. I think you know a lot more than I do, so apparently it is just my understanding of your recommendation.

    As far as I am reading it, you are suggesting to total each month, then see if each month is less or greater than column M?

  • Re: Sum columnA/sum columnB, if row Has data up to columnB


    no on the contrary, you know much more about this than I do :=)

    I came up with that suggestion just by looking at your formula and the workbook you supplied. I don't know about your data. So from that, I see

    - that the formula is going line by line doing the same calculation many times, namely

    ..which is a comparison of the amount paid to date against the promised amount.

    I don't see an easy way to simplify this formula that will reduce the calculation time. So, instead of doing this conditional test a hundred times, why not take it out of the formula and keep the result of the test somewhere else, ie in a different sheet?

    For example in your front sheet in cell P5, the formula performs the conditional test using the addition of the amounts paid from Jan to Mar (N18-P18).

    (Apologies if these are not the correct refs as I've opened this up on my netbook using xl2003 and it's converted it into read only)

    What you can do is create a replica of this worksheet; just copy and paste it and remove all the monthly amounts paid.

    Now, instead of $50 in cell P18 on the copied sheet, you have a cumulative total so that it would be Jan + Feb + Mar. ie $150.

    Now, you can copy the sheet again, or create space on the same sheet to do the <>M column test. This will mean that you have an actual cell where you have the result of the test rather than doing it all in one go in your megaformula.

    Once you have these intermediate results in actual cells, you can remove them from your megaformula entirely and reference the CELLS themselves on the copied sheet that compute the test, rather than doing the test ie.
    IF(SUM($N$13:W13)<1,0,$M$13) the cell itself

    Because the copied sheet will be exactly the same as the original, you can reference the cells and copy them down/across in the original sheet easily

    Basically you're just chopping up the original megaformula and performing the tests inside them in other cells on a copied sheet. You then reference these cells in the original formula which will turn your formula into a one liner rather than a one hundred liner

  • Re: Sum columnA/sum columnB, if row Has data up to columnB


    Okay so I took some time to do it now. It looks like it is going to work, and this might help me with some of my other problems as well. After making the second page my new formula looks like this


    It is an array formula. I may have gone heavy on the () but I always add a few extra just in case.
    At least it appears to work and does it great. Now I just have to apply this new fun working with two worksheets into my other questions.

    Thank you again for your help,

  • Re: Sum columnA/sum columnB, if row Has data up to columnB

    Good job! Yeah that would work. Just be mindful that hundreds of array formulas may also slow your workbook down. (no one said it was easy)

    Not a problem, glad to be of use :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!