Adding a range of cells to one cell based on a condition - if-statement

I have a sheet in Ms Excel with Loan details, where the loan status is either 'Paid' or 'Unpaid'. For every row, I want to add the amount value to cell C18 if the corresponding cell in status column reads "Unpaid".
eg. for row 10,
=IF(J10 ="Unpaid", $C$18+G10, $C$18+0) **{This does not work}**
How can I achieve this so as to use the formula for a couple of rows?

You might try ...
=C$18+(J10="Unpaid")*G10
This formula will add C18 to G10, but only if J10 says "Unpaid", otherwise, it will just add C18 to 0.
It can be "dragged down" for the other rows, and the '$' on C$18 will keep that cell fixed while the references for J and G will correspond to the row that the formula is in.

My guess from what you're saying is that you want to add column G only when the corresponding value in column J = "Unpaid".
If so, the formula you put in C18 is =SUMIFS(G:G,J:J,"Unpaid") or =SUMIFS(G10:G,J10:J,"Unpaid") if you want to start the sum at row 10.

You can't add to $c$10, only to a new column, lets say called 'balance'. There (column k) would be the formula =$k9+if($j10="Unpaid",$g10,0)

in Google Sheets:
=ARRAYFORMULA(IF(J10:J50="Unpaid"; C18+G10:G50; C18))

Related

Sum the Column A Only if Column B contains?

I have the table in google-sheets which looks:
I need to sum sums according to the Card = "HDFC"
i.e need to display in cell 1408.8
Need help here.
I Tried:
=COUNTIF(C3:C1000,"HDFC")
but its give count only not sure how to use to get sumif on column B if matches column C
Simple SUMIFS() must work. Try-
=SUMIFS(B4:B,C4:C,E4)
or these:
=SUM(FILTER(B:B; C:C="HDFC"))
=INDEX(QUERY(B:C; "select sum(B) where C = 'HDFC'"); 2)

How to count the number of blank cells in one column based on the first blank row in another column

I have a spreadsheet set up with tv program titles in column B, the next 20 or so columns are tracking different information about that title. I need to count the number of blank cells in column R relating to the range in column B that contains titles (ie, up to the first blank row in column B.)
I can easily set up a formula to count the number of empty cells in a given range in column R, the problem is as I add more titles to the sheet I would have to keep updating the range in the formula [a simple =COUNTIF(R3:R1108, "")]. I've done a little googling of the problem but haven't quite found anything that fits the situation. I thought I would be able to get the following to work but I didn't fully understand what was going on with them and they weren't giving the expected results.
I've tried these formulas:
=ArrayFormula(sum(MIN("B3:B"&MIN(IF((R3:R)>"",ROW(B3:B)-1)))))
=ArrayFormula(sum(INDIRECT("B3:B"&MIN(IF((R3:R)>"",ROW(B3:B)-1)))))
And
=if(SUM(B3:B)="","",SUM(R3:R))
All of the above formulas give "0" as the result. Based on the COUNTIF formula I have set up it should be 840, which is a number I would expect. Currently, there are 1106 rows containing data and 840 is a reasonable number to expect in this situation.
Is this what you're looking for?
=COUNTBLANK(INDIRECT(CONCATENATE("R",3,":R",(3+COUNTA(B3:B)))))
This counts the number of non-blank rows in the B column (starting at B3), and uses that to determine the rows to perform COUNTBLANK in, in column R (starting at R3). CONCATENATE is a way to give it a range by adding strings together, and the INDIRECT allows for the range reference to be a string.
a proper way would be:
=ARRAYFORMULA(COUNTBLANK(INDIRECT(ADDRESS(3, 18, 4)&":"&
ADDRESS(MAX(IF(B3:B<>"", ROW(B3:B), )), 18, 4)))
or shorter:
=ARRAYFORMULA(COUNTBLANK(INDIRECT("R3:"&
ADDRESS(MAX(IF(B3:B<>"", ROW(B3:B), )), 18, 4))))
or shorter:
=ARRAYFORMULA(COUNTBLANK(INDIRECT("R3:R"&MAX(IF(B3:B<>"", ROW(B3:B), ))))

Formula to return TRUE if Criteria Matches?

The reason I am posting this question is that combining Index and Match functions only searches for first qualifying row from top-down and I am needing to find next row up from current that matches as part of my formula.
The complete formula I am trying to construct is to return TRUE in cell "C4" if equal to the row that has the lowest value in column "A" from just above a value (nonblank) in column "C" to just before numbers in column "B" go above 55. So in this case, it would return TRUE in cell "C4" because for the blue highlighted area value 28.28 is lowest in column "A".
Secondarily not sure if INDIRECT function is best to use since I have a few hundred of these in my sheet. Is this a resource hog when I need these to calculate quickly???
I have it posted here and am posting it here because I am trying to get this to work in Sheets which I know is often different than Excel.
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_win10-mso_2016/formula-to-return-true-if-criteria-matches/02834e93-c29f-449d-ace0-98722c399e63?tm=1568399215380
perhaps like this:
=ARRAYFORMULA(IF(A1:A=MIN(FILTER(A1:A, B1:B<55)), TRUE, ))

Arrayformula count how many cells in a row are less than cells in another row only if both are nonzero/nonblank

I found this formula, =arrayformula(sumproduct($C$24:$C$31<B$24:B$31)) but I need it to ignore if one or both cells are 0 or blank.
I've tried and, and countifs, but I can't seem to figure it out.
=arrayformula(sumproduct($C$24:$C$31<B$24:B$31))
I want a number 0-8 for counting how many cells in the particular row are less than the compared row, but (i.e. 0<25) needs to be ignored.
try it like this:
=ARRAYFORMULA(SUM(IF((C2:C < B2:B) * (C2:C<>0), 1, 0)))

How to populate a value when comparing two columns, VLOOKUP or IF?

I'm trying to create "Sale Rep" summaries by "Shop", where I can simply filter a column by the rep's name, them populate a total sales for each shop next to the relevant filter result.
I'm using this to filter all the Stores by Scott:
=(filter(D25:D47,A25:A47 = "Scott"))
Next, want to associate the Store/Account in F to populate with the corresponding value of E inside of G. So, G25 should populate the value of E25 ($724), G26 with E26 ($822), and F27 with E38 ($511.50)
I don't know how to write the formula correctly, but something like this is what I'm trying to do: =IF(F25=D25:D38),E25 I know that's not right, and it won't work in a fill down. But I'm basically trying to look for and copy over the correct value match of D and E inside of G. So, Misty Mountain Medicince in F27 will be matched to the value of E38 and populated in G27.
The filter is what's throwing me off, because it's not a simple fill down. And I don't know how to match filtered results from one column to a matched value in another.
Hope the screenshot helps. Screenshot of table:
Change Field Rep: Scott to Scott and you might apply:
=query(A25:E38,"select D,E where A='"&F24&"'")
// Enter the following into G25 and copy down column G
=(filter(E25:E47, D25:D47 = F25))
or
// Enter the following into G25 will expand with content in F upto row 47
=ArrayFormula(IF(F25:F47 <> 0, VLOOKUP(F25:F47, D25:E47, 2, FALSE),))