How to calculate the total difference in merged cells - google-sheets

As you can see on the image, I have lots of different categories (laptops, mobile phones, etc.). I want to calculate the total revenue from the lot I have. Since each lot has its own quantity, I cannot apply the unique formula of the difference here.

Well, you can use sumproduct() like this:
=SUMPRODUCT(D3:D8-C3:C8)
Not typing in more data but you can expand it as needed.

=SUM(INDIRECT("D"&ROW(E11)&":D"&ROW(E11)+MATCH(TRUE,INDEX(ISBLANK(D11:D),0),0)-2))-SUM(INDIRECT("C"&ROW(E11)&":C"&ROW(E11)+MATCH(TRUE,INDEX(ISBLANK(C11:C),0),0)-2))

Related

Is there a google sheets function to count with using arrays of sums as criteria?

I have been struggling for a few days with this problem. Anyone kind enough to show some interested will be highly appreciated.
I have the table shown below.
Suppose columns represent months. I would like to know up to which months' orders have been used up.
I have tried criteria with sums of demand up to that point but I cannot seem to use criteria with the sum of total demand and an array of sums of "total units ordered".
F.e. =COUNTIF(SUM($S$2:($S$2:S$2))<SUM($S$1:S$1) is not possible.
I have tried using an index-match combo but i would have to deduct the previous max sum of "total units ordered" that meets the condition up to the previous cell.
Is that possible without using vba?
Thanks in advance for your interest and time spent.
You can use a standard method of getting running totals using Sumif, combined with Match:
=ArrayFormula(match(sumif(column(S1:Z1),"<="&column(S1:Z1),S1:Z1),sumif(column(S2:Z2),"<"&column(S2:Z2),S2:Z2))-1)
I put rows 3 and 4 in just as a check of my calculations and to show the results of the two Sumifs evaluations - they aren't necessary.
You may wish to specify what should happen if the demands add up to exactly 3000, for example. The above formula would actually go to the next month, so may need some refinement if that is not what you want.

How do I use Number Formatting in Google Sheets to display an UNSIMPLIFIED, NON-reduced fraction?

I'm building a progress tracking worksheet at the moment. I use Checkboxes to mark tasks as complete, and I have a simple formula to check "how many are done (true)" / "how many there are".
=COUNTIF(M7:Z7,TRUE)/(COUNTA(M7:Z7))
This was successful, and got me the percentages I needed for my progress bars, but it wasn't as useful as I was hoping because I realized I wanted to keep track of the precise quantity of remaining items in addition to the total completion rate.
So I did some digging and found the custom number formatting options in sheets, and was able to use this format to change my calculation into a non-mixed fraction:
_# ??/??
So THAT worked just fine until I realized it was treating it like, well, an actual fraction and trying to simplify it all the time. I don't want to know that I've done 1/7th of the things, I want to know that I have done 2 out of 14 things.
The reason I noticed this problem in the first place is because when it hit "100%" for one of the task categories, it went from "13/14" to just the whole number "1," which is the opposite of what I want; I want it to still show the fraction, as "14/14."
I feel like I've been spinning my wheels for so long now, I'm not sure how much better to do this WITHOUT having to completely restructure my sheet and formulas and add some stupid hidden math columns in between what I already have built.
Ideal solutions would just be some secret in the Number Formatting options. But I absolutely cannot use a static denominator in the number formatting. At this point I'm not sure what kinds of other options there are to be honest.
tl;dr
In Google Sheets, what's the best way to display an unsimplified fraction with a non-static Numerator and Denominator?
If what you want is to visualize the fraction, but not use it for further calculations. You could simply display is as a string.
For example:
this: =COUNTIF(M7:Z7,TRUE)/(COUNTA(M7:Z7))
becomes
this: =COUNTIF(M7:Z7,TRUE)&"/"&COUNTA(M7:Z7)
Note:
Keep in mind COUNTA counts all the values in the range, not just the number of rows (Which I assume is the number of tasks).
You may want to change the range passed to COUNTA to be a single column.

How to combine dynamic ranges with OFFSET and INDIRECT functions?

I'm trying to create a formula that uses a dynamic range to link to the different tabs. It would then return the last 12 values before a blank cell, based on the value in the Header Column.
The tricky part is the data in each tab is of different sizes, so I thought it might have to incorporate either Offset(Blank()),0,-12) or something of the sort. I've tried a lot of different things, and this is the latest effort:
=Index(Indirect(A2&"!A9:AK9"),match("Conversions",Indirect(A2&"!A9:AK9"),)0,-12)
Edit: First post, sorry for the confusion. My goal is to make a large dashboard that has a dynamic chart using our monthly metrics. (I'm leaving the chart setup for another day)
The data varies in such, some have columns A:K, while some have a larger range of A:AK , etc. (With A:A being text). Since I've posted this, I have had some success by using Filter(), but the problem I'm not sure how to solve is finding the last 12 values before a blank cell.
Example of Data 1
Example of Data 2
Hopefully this helps explain the situation and I appreciate everyone for help.

Google Spreadsheets: Sum over multiple criteria constrained by timeframe

Hello Everyone (this is all in Google Spreadsheets),
I'm trying to make a report where I have to sum the product of the number of Apples and Bananas bought respectively within a certain time frame by different people. The price of the goods differs, depending on who is buying them. The people who buy it do so at different times and purchase a different number of items. The formula should be extendable to include additional people in the future.
For details see this Google Spreadsheet.
I would like to get the calculation without needing steps in-between. If it makes any difference, the number of items bought on specific dates are actually in different worksheets, so they're not on the same page as in the example. I named the ranges accordingly (even though I believe/hope it makes little difference in terms of what formula to use).
Finally, if it were possible to use one formula for the total expenditures, instead of the sum over the cells above that would be grand.
I use the DATEVALUE, because otherwise I wouldn't be able to find the first and the last date of the calendar weeks. There is a dedicated DATEVALUE column in every worksheet. (Additionally, I don't have to deal with the intricacies of the date format, which gets me every time.)
I hope I didn't miss an answer to my problem and provided enough information. I can't get my head around it, I am really looking forward to your answers.
Thank you everyone :)
Greg
P.S. A picture of the sheet, if required: Apples, Bananas & €
Credit to Sennsei from the Google Docs Help Forum (Link). I quote:
I won't be surprised if this isn't the best way to go about this, but regardless, here's my take on solving your problem. Result is based on this modified worksheet.
Apples:
=IFERROR(SUM(ARRAYFORMULA(ARRAYFORMULA(VLOOKUP(FILTER('Prices/Amounts'!$J$4:$J,'Prices/Amounts'!$K$4:$K>=B4,'Prices/Amounts'!$K$4:$K<=B5),FILTER('Prices/Amounts'!$J$4:$L,'Prices/Amounts'!$K$4:$K>=B4,'Prices/Amounts'!$K$4:$K<=B5),3,0))*ARRAYFORMULA(VLOOKUP(FILTER('Prices/Amounts'!$J$4:$J,'Prices/Amounts'!$K$4:$K>=B4,'Prices/Amounts'!$K$4:$K<=B5), 'Prices/Amounts'!$B$3:$D,3,0)))),0)
Bananas:
=IFERROR(SUM(ARRAYFORMULA(ARRAYFORMULA(VLOOKUP(FILTER('Prices/Amounts'!$F$4:$F,'Prices/Amounts'!$G$4:$G>=B4,'Prices/Amounts'!$G$4:$G<=B5),FILTER('Prices/Amounts'!$F$4:$H,'Prices/Amounts'!$G$4:$G>=B4,'Prices/Amounts'!$G$4:$G<=B5),3,0))*ARRAYFORMULA(VLOOKUP(FILTER('Prices/Amounts'!$F$4:$F,'Prices/Amounts'!$G$4:$G>=B4,'Prices/Amounts'!$G$4:$G<=B5), 'Prices/Amounts'!$B$3:$D,2,0)))),0)
Expenditure:
=B7+B8
The B4's and B5's refer to the date constraints. Since the formulae contain $ signs to ensure the cells stay the same, the formula can be dragged across to apply to other weeks without having to touch the formulae. As a plus side, these formulae allows a sheet to be infinitely expandable!
Sennsei

How to use Sumif in Google sheets with many ranges?

I have a spreadsheet that has summary information for individuals by month, and I want to sum the information for all participants, but I need to break it down conditionally by year. The big issue is that the information is not all stacked on top of each other in two columns(month & info), they are broken up by person with titles in between, so I have to use multiple ranges.
For example, my code now looks something like this:
=sumif([A2:A6,A9:A17,A19:A25], "<13", [D2:D6,D9:D17,D19:D25])
Except I am doing this with hundreds of ranges. The brackets are not working and I am not sure how to use an Array. I would really appreciate someones help on this, as I have been racking my brain for awhile now.
Maybe:
=sumif(A:A,"<13",D:D)
or, if there are values in row26 or below and in row1 to be excluded:
=sumif(A2:A25,"<13",D2:D25)
If I got you right, the following would work:
=sum(filter(D2:D25,ISNUMBER(A2:A25),A2:A25 >13))
The idea:
Filter for rows that are numeric (you said the content in between are titles!?) and meet your requirement (>13).
Sum it up! (By the right column)

Resources