google-sheetsgoogle-sheets-formula

Need help creating a formula


I am trying to make a formula that tracks the amount of pages I read per month but only counts a percentage of the books I DNF'd (did not finish).

This is the current formula I have (using the month of "June" as an example):

=SUMIF(MonthRead,"June", PagesRead)-SUMIFS(PagesRead, MonthRead, "June", Rating,"DNF")+ROUNDDOWN((SUMIFS(PagesRead, MonthRead, "June", Rating,"DNF"))\*(SUMIFS(DNFPer,MonthRead,"June",Rating,"DNF")))

The formula does work... but only if I have one DNF that month. If I have more than one, it messes up the math (see below):

Monthly Stats tab:

Monthly Stats tab

Books Read tab:

Books Read tab

For June, I only tried to read one book, and I DNF'd it. The book is 466 pages long, and I only read 5% of it, so the amount of pages I read is 23. This is correct in the Monthly Stats tab.

In September, I DNF'd two books. If you add up the pages from the books I read plus the percentage of pages I read for the DNF'd books, you get 791. However, the Monthly Stats page doesn't reflect this; it instead says 918. I can't figure out why this is the case and would love some help figuring this out.

Link to sheet if needed: https://docs.google.com/spreadsheets/d/1-DPAkUp_lendM-7qZ1lOt4siYWRq1C_QpHt47Fwl20g/edit?gid=2137092447#gid=2137092447


Solution

  • You may test this for September & adapt it for other months as well:

    =rounddown(sumproduct(MonthRead=Z2,PagesRead,if(DNFPer,DNFPer,1)))
    

    enter image description here