Countifs formula - google-sheets

I am new to google sheets. I have a spreadsheet with two tabs that are involved with this question:
DB - Dental
RPT - Billing Dental
On the RPT tab, I am trying to create a countifs formula to count the number of patient records for which no billing activity has yet occurred.
My basic countifs formula looks like this:
=countifs('DB - Dental'!F3:F845,A3,'DB - Dental'!AC3:AC845,"")
Row 845 is the last row of data entered into the DB tab.
I now want to replace the 845 reference in this formula and make it instead automatically figure out what the last row number in my DB tab is so it will dynamically grow as more records are entered into the spreadsheet.
The formula I have for figuring out the last row of data in the DB tab is this:
=(max(arrayformula(if('DB - Dental'!A:A<>"",row('DB - Dental'!A:A),""))))
Both formulas work separately. The question is how can I merge them together so the countif function reads from row 3 to the last row of data in the DB tab?
Thank you very much for your help!

Assumptions|
It would be much easier to have some sample data you are working on. Based on information you gave, the second formula you have written -
=(max(arrayformula(if('DB - Dental'!A:A<>"",row('DB - Dental'!A:A),""))))
just counts rows that are not empty in A column.
If that is true,
then you would archive the same just using
=COUNTA('DB - Dental'!A:A)
From this point you need to use this to generate final range in you basic countifs formula. You need INDIRECT function to be involved, like that:
INDIRECT("'DB - Dental'!F3:F"&COUNTA("'DB - Dental'!A:A"))
Final formula
=countifs(
INDIRECT("'DB - Dental'!F3:F" & COUNTA("'DB - Dental'!A:A")),A3,
INDIRECT("'DB - Dental'!AC3:AC" & COUNTA("'DB - Dental'!A:A")),""
)
Should work - but if you gave your sample data, then I could verify it first... :)

Related

Counting occurrences of a phrase in Google Sheets using ArrayFormula

I have a formula in Google Sheets that counts the number of times a phrase has occurred in another column up to and including the row.
="BMC - Thursdays"&":"&COUNTIF($C$1:C1,"*BMC - Thursdays*")
This formula is in A1, and when I drag this down, it automatically adjusts it so that in A2, it searches cells C1 and C2, in A3 it counts occurrences in C1, C2, and C3, etc.
Unfortunately, all of my new data is imported from paperform, which creates a new row each time. I would love it to automatically run that formula on the new row. I have tried doing this several ways using an arrayformula, but I've been unsuccessful, I just don't know enough to come close. It work perfectly when I drag the formula down from already existing columns, so have no idea why there isn't an easy way to do this (that I've been able to find yet).
Any help is much appreciated. Thanks!
An example sheet of what I'm looking for can be found here:BMC Tally Sheet
See if this works
=ARRAYFORMULA(IF(LEN(C:C), "BMC - Thursdays"&":"&COUNTIFS(C:C, "*BMC - Thursdays*", ROW(C:C), "<="&ROW(C:C)),))

Google Sheet SUMIF not summing range

I am trying to SUM all rows based on the condition that a row's value is greater than 0. However, the formula is only calculating the first row and ignoring the rest of the range. I encountered this issue on a different spreadsheet but I isolated the issue on a new spreadsheet to show you and ask questions.
The answers should be B1 ($5), B2 ($15), B3 ($30).
I followed the formula's usage as explained in the Google Docs https://support.google.com/docs/answer/3093583?hl=en
The formula with respective row number =SUMIF(A1, ">0", A$1:A1)
Update - The below is my intended purpose. I have a spreadsheet that calculates money In and Out. For each of these transactions, I simply want the balance as a result of such transactions. This only works for the first row. (I hardcoded the values for the rest of the rows just to show my goal.)
try:
=ARRAYFORMULA(IF(A:A="",,SUMIF(ROW(A:A), "<="&ROW(A:A), A:A)))
if you prefer dragging do:
=SUMIF(INDIRECT("A1:A"&ROW()), ">0")
UPDATE:
=ARRAYFORMULA(IF(D2:D="",,
SUMIF(ROW(D2:D), "<="&ROW(D2:D), D2:D)-
SUMIF(ROW(E2:E), "<="&ROW(E2:E), E2:E)))

Google Sheets: How to use arrayformula to find and get data from only a certain, dynamic set of columns

I have a Google sheets table where my headers are dynamically generated from another source, and can show up with any header values, in any order.
In the link example I've got the header values: AA - BB - CC - ABBA - KK - VV but it could just has well been: CC - AA - QQ - YY
I don't know in advance which headers I will get, or how many.
My issue is that I want to sum each product values, per row, using an arrayformula, where the column headers include for instance "BB".
So basically =arrayformula(sumifs(G4:L1000,$G$3:$L$3,"BB")), if that had been a thing.
My closest guess is that I need to use a VLOOKUP of some sort, but since the index of the columns to get the data from isn't static I can't quite figure out how to solve it.
Desperate for help.
https://docs.google.com/spreadsheets/d/1ZcMldTJrFLz_f_w-lGMIuAKs_yGSc1eDXbA2tgr9Bw4/edit?usp=sharing
I can get arrays of all the headers that match my query (in B4:B):
=TRANSPOSE(SPLIT(arrayformula(CONCATENATE(IF(REGEXMATCH(G3:L3,"BB"),G3:L3&"~",""))),"~"))
and then get the column indexes (in C4:C):
=iferror(arrayformula(match(B4:B,$G$3:$L$3,0)+6),"")
or even column letters (in D4:D):
=iferror(arrayformula(REGEXEXTRACT(ADDRESS(ROW(), indirect("C4:C"&counta(B4:B)+3)), "[A-Z]+")),"")
and then I had some half baked idea of using this in the vlookup, but now I'm just completely and utterly stuck.
You could create an intermediate table using
=filter(F3:L, arrayformula(regexmatch(F3:L3,"BB")))
and then use SUM on each resulting column to get what you need. If the FILTER results begin on row 2, then you can place the SUM functions on row 1 so they won't get in the way of the FILTER expansion.

How To Make Pie Graph become case insensitive

I am adding pie charts into a Google Sheets page, but they are just messy.
This is because the data it is pulling from has (distinct) but minor differences between each other. To put it more easily:
Roofer and roofer are showing as 2 separate slices in the chart.
I want the processing to be case-insensitive, considering Roofer and roofer as the same category.
Can this be done in Google Sheets? How about excel?
Same data and sheet:
https://docs.google.com/spreadsheets/d/1YlNXVs6yljh339b84YVsjiMSaYxt76n13bWGbuM-iBk/edit?usp=sharing
The only easy way I see to do this is to insert helper columns to clean the data. Then graph the clean data.
Using this technique produces this result - based on graphing colC.
The formula in cell B2 - to remove spaces - is:
=arrayformula(TRIM(SUBSTITUTE(A2:A20, " ", "")))
The formula in cell C2 - to convert case - is:
=iferror(arrayformula(upper(left(B2:B20, 1)) & lower(right(B2:B20, len(B2:B20)-1))),"")
The data range on the chart is C1:C1000
You can hide Cols A and B for display purposes.
Alternatively move the helper columns to out of view columns.
The idea with this is you type the raw data into col A as shown, and the clean data appears in ColC.

2 Google Sheets Workbooks linked via importrage - how to add new row in one workbook and not affect other

I have 2 google workbooks. One is a rate sheet and the other is a vendor list with pricing.
I have the vendor list with pricing workbook linked to the rate sheet workbook via importrage command. This works great and everything updates as it should until you add a new line or remove a line to the rate sheet workbook. At this point the vendor workbook does not update the reference and just still points at the same lines it was originally, now displaying the incorrect data.
How can I dynamically have the vendor list workbook notice the addition or removal of lines in the rate sheet workbook and update the importrange formula?
Can this be done?
Any help is greatly appreciated.
EDIT: I have prepared 2 sample workbooks. They are Test sheet 1 - Rates and Test Sheet 2 Lanes
I have all of our rates in the first sheet. In the second we would have vendor lanes. This sheet consists of multie tabs all with an individual lane that is linked to 1 row in the rates sheet.
In the lanes sheet I have linked the two together via importrange in cell A8. Now this works and links properly, that is until you insert a new line in the rates sheet above the one the lane is linked to and then it doesn't update but shows what the new line information is.
Is there a way to have the lanes sheet dynamically update to the next line when a new line is inserted in the rates sheet?
two sheets links are as follows:
Rates
Lanes
Solution 1 - if you need to check only one condition
To achieve desired result you have to have something like an ID for every rate. For sake of this answer (based on your example sheets) I assume that this could be an Origin City. In Test Sheet 2 I have added new sheet - SheetTest where:
First step
I am looking for the row number where desire City reside in Rates sheet (in example - its Mcclellan city). The code for that is simple:
MATCH(A2,IMPORTRANGE("https://docs.google.com/spreadsheets/d/1JD45y-0-37Kh2KsHnRAMuB0quPtMVuLKuT1qjnNcm1Q/edit","Rates!B:B"),0).
This gives me -> 10
Second step
I use this result to dynamically generate final range - "Rates!A10:X10". The final result in A8 cell is (to make it clearer, I change an address of a sheet to -othersheeturl- :
=IMPORTRANGE(
"-othersheeturl-",
"Rates!A"&
MATCH(A2,IMPORTRANGE(-othersheeturl-","Rates!B:B"),0)
&":X"&
MATCH(A2,IMPORTRANGE("-othersheeturl-","Rates!B:B"),0)
)
Working example
Warning
I see that in your original sheet you use "take" Origin City from Rates sheet, so I remove this dependency in A2 to make it an ID. I hope this solves your problem.
Solution 2 - if you need to check many conditions
An approach is the same, but tools are different. Main goal is to find a row number that meets criteria - "From City" and "To City". Then this row number will be used to concatenate desire range.
First step - some cleaning
To better manage complex formulas its a good idea to divide them into smaller pieces - like in "ordinary" programing. So, we have:
From City in A5
New Albany
To City in B5
Calgary
Rate sheet (external sheet) url in B1:
1JD45y-0-37Kh2KsHnRAMuB0quPtMVuLKuT1qjnNcm1Q
You don't have to put whole URL, only this part is needed
Formula that counts row number that we are looking for in B2
=QUERY(
{IMPORTRANGE(B1,"A1:B"),
ArrayFormula(row(INDIRECT("A1:A"&ROWS(IMPORTRANGE(B1,"A1:B")))))},
"select Col3 where Col1='"&B5&"' and Col2='"&A5&"'
limit 1")
Above code:
Build an array from Rate sheet (external) - columns A1:B and virtual index that represents rows numbers
Then, show only column nr 3 (index) where Col1 matches our "To City" and Col2 matches "From City"
At the end is a limit to only one result (in case that there are more then one maches)
Desire range in B3
="Rates!A"&B2&":X"&B2
Final formula that renders desire data from external sheet in A11
=IMPORTRANGE(B1,B3)
Working example
Final thoughts
You can either hide rows 1-3 or you can pack all above formulas into one. Its up to you. I prefer the first approach.
This solution gives you freedom with as many conditions as you want
More info would be helpful.
A couple ideas:
Using named ranges instead of a static reference. For example, if you create a named range in the rate sheet called MY_DATA that references A2!C600, you can include "MY_DATA" in your importrange in the vendor sheet. Note that you'd still need to update MY_DATA every time you add a row.
If you're importing the entire sheet, perhaps omitting the end row would work (e.g. A2!C instead of A2!C600) - note that this means you need to use filter or query in the Vendor sheet to eliminate the blank rows.

Resources