Home > Mobile >  How to get sum/difference From a different sheet using dates as reference?
How to get sum/difference From a different sheet using dates as reference?

Time:08-10

Collections Sheet

Expenses Sheet

Hi, I would like to get the daily sum/difference of the expenses from the expenses sheet then output to collections sheet using dates as reference/identifier.

I tried this code =MINUS(C8,INDEX(Expenses!20:31,12,2)) but I want it to auto compute when I drag the box. sorry for bad english. thank you

Desired output:

Desired Output

Output at (Net) Cash On Hand Row / Reference Date Column, the output should be August 1 Collection - August 1 Expenses.

CodePudding user response:

The main issue is with the structure of your expense sheet, since you need to use only every second column. For this you can use various methods, something like

=split(substitute(join(";",Expenses!A2:DJ2),"Total:;",""),";")

The join function takes the whole row and joins it into one string, the substitute function removes the Total: from it, along with the trailing ; and the split function separates it again to separate values. This will be an array, automatically spread out to 31(-ish) columns width if entered into a cell like C10 on your Collections sheet.

Then you have two options, simply do =C8-C10 in C9, which you can drag with no problem. You can also hide the row 10 by making the text color white, or even integrate it in that sheet.

My recommendation however is not to do any of that, instead enter the formula

=arrayformula(C8:AG8 - split(substitute(join(";",Expenses!A2:DJ2),"Total:;",""),";")

into C9 on the Collections sheet and it's taken care of, without the need to drag it out. You might need to tweak it, not sure if the AG8 and DJ2 are the correct columns to end them on (should be the last column if every column or every 2 columns is a day). The arrayformula makes sure that the subtractions are done automatically for each pair of values, and expanded automatically into the row. Make sure that there are no values or formulas in D9:AG9, so it can fill up the values automatically and you don't get a #REF error.

  • Related