Google Sheets - COUNTIFS in ArrayFormula - arrays

Project Completion Target Date
Estimated Completion Date
12/31/2020
12/24/2020
12/31/2020
1/7/2021
1/19/2021
2/15/2021
I'm trying to create a CountIfs statement, or a CountIf inside an Array, which will evaluate one column in relation to another column, repeated for multiple rows. With multiple conditions: If B > A, and ignore the row is A is empty.
Formula So Far:
=COUNTIF({B2:B5}, ">"&{A2:A5})
Result is 3, but the desired result is 1. This formula is counting when B > null = True. But desired result is when A is empty/null, then B !> A.

Here's one option.
=COUNT(FILTER(A2:B5,NOT(ISBLANK(A2:A5)),B2:B5>A2:A5))/2
You can use FILTER() to filter your data with multiple conditions then count the filtered data (divide by 2 based on the number of columns in your data)
Your conditions:
A should not be empty
B should be greater than A
Example:
Filter the set of data based on the conditions required.
=FILTER(A2:B5,NOT(ISBLANK(A2:A5)),B2:B5>A2:A5)
Output:
It will return a filtered data like this.
Then you just need to use COUNT() to count the filtered data. You just need to divide the result of the count based on the number of columns in your data.

You can also use the following filter formula
=COUNTA(FILTER(B2:B7,A2:A7<>"",B2:B7>A2:A7))

Related

How to specify a column field in a calculated field formula when you have the same value evaluated as a count and a sum?

I am using a pivot table to summarize our status of completion of a project. The first value of the pivot table gives me a count of the entries in the spreadsheet column that have a value greater than 0. The next value of the pivot table gives me a count of the total estimated quantities from the spreadsheet. The third value gives me the sum of the entries from the same column of the spreadsheet that the first value uses in the pivot table. The final value of the pivot table is a sum of the total estimated quantities from the same column from the spreadsheet the second values uses for the pivot table.
My current working formula will only evaluate the SUM columns in the pivot table and is the following:
=iferror('Quantities Complete'/'Total Est Quantities',0)
This gives me a percent complete based on the SUM of those two columns from the spreadsheet. These values can differ because the first is a real value and the second is an estimated value. What I want is the below formula which I will put how the data is summarized in parenthesis for simplicity of understanding.
=if('Quantities Complete'(COUNT)='Total Est Quantities'(COUNT),1,iferror('Quantities Complete'(SUM)/'Total Est Quantities'(SUM),0))
This formula would allow me to evaluate if the count of complete items matches the total estimated items, if so the calculated field value is 100% regardless of actual sum values. Otherwise, it gives a percent complete based on sum value which is more accurate because each item can have vastly different values.
How can I refer to the 2 different uses of the columns in a calculated field formula?
I have tried the renaming the column headers to 'Items Complete' and 'Item Values' but the formula does not accept those and gave a parse error. I have tried using the "COUNTA of" or "SUM of" prefix for the column fields. I also tried typing the name as shown when I hover over the value field in the edit window which I tried in these methods: 'Quantities Complete' (Items Complete) and 'Quantities Complete (Items Complete)'. All of these yielded a parse error. I can't share my spreadsheet due to confidentiality requirements, but all I need to know is how to refer to the two different column headers that have the same name from what I can tell.

How do I change my multi criteria Index Match formula in such a way that it sorts results closest to today?

How can do I write an array formula in such a way that both following factors apply:
Results give me the names of sales that have either TRUE OR FALSE next to it in a different column/sheet.
Results are sorted chronologically based on the date that is connected to each sale. Each sale has a different date next to it. This can be found in the same sheet as where the "TRUE OR FALSE" result is displayed. Column with the dates is called "AY:AY". I use an indirect formula to target the correct sheet within the spreadsheet.
I currently only have the first criteria implemented, don't know how to do the 2nd one.
Since the raw data is not ordered I need this to happen when I use the Index Match Array formula. So far I have this formula in my Google Sheets spreadsheet.
=ArrayFormula(iferror(index(indirect("'"&$B$5&" 2023'!c:c");small(if(TRUE=indirect("'"&$B$5&" 2023'!ca:ca");row(indirect("'"&$B$5&" 2023'!ca:ca"))-row(indirect("'"&$B$5&" 2023'!$ca$1"))+1);row(1:1)));""))
I know I could use the Index Array formula below with multiple criteria, but don't know how to implement the date component.
INDEX(indirect("'"&$B$5&" 2023'!c:c");SMALL(IF(COUNTIF(_______)*COUNTIF("true"; indirect("'"&$B$5&" 2023'!CA:CA"); ROW(indirect("'"&$B$5&" 2023'!A:CA"))-MIN(ROW(indirect("'"&$B$5&" 2023'!A:CA"))+1); ROW(indirect("'"&$B$5&" 2023'!A1));COLUMN(indirect("'"&$B$5&" 2023'!A1))
Thanks in advance.
A query like this could help?
=QUERY(INDIRECT("'"&$B$5&" 2023'!C:CA"),"SELECT C,AY WHERE CA = TRUE order by AY")

Arrays, SUM + INDEX/MATCH

Note: tried in Excel and Google Sheets, but I have a preference for Sheets.
Basically I want to get the sum of a group of data using INDEX and MATCH (because the parameters are going to be drop-down dependent):
The desired result is:
So this will require a few things:
Converting the cell D13(April) to a Month
Converting the "weekof" column to a Month
Using INDEX and MATCH and MATCH again, I'm assuming because it's multiple cell references.
Here's my solution currently below:
=SUM(INDEX(D5:I9, MATCH(MONTH(D13&1),ARRAYFORMULA(MONTH(C5:C9)),0), MATCH(E12,D4:I4,0)))
This returns the NEAREST value:
270
Instead of:
804
Why this value?
270+500+34 = 804
If you are not strict to use INDEX and MATCH, you may use the following solution:
Add extra column name it "Month", this column will extract the month name from the date column using TEXT function as the following:
=IF(C3<>"",TEXT(C3,"mmmm"),"")
The if statements ensures that only filled dates will have a month value, since you have to fill this column with the above formula for a certain amount of cells.
Now you can simply use the SUMIF function in cell E13 or where ever you want:
=SUMIF(B:B,D13,D:D)
If you don't want the Month column to appear within your data table you may put it at the end of your table and hide it.
You could directly use FILTER then SUM the result instead to simplify your formula to this one:
Formula:
=SUM(FILTER(D:D, TEXT(C:C,"MMMM") = E13))
Output:
UPDATE:
The above formula should also update when the value is dropdown. Dropdown is just data that can be changed with predetermined values, aside from that, it should be the same when using a normal cell.
To match columns, use MATCH and INDEX together with the formula above. See modified formula below.
Be careful of the circular dependency. make sure your ranges doesn't interfere with the actual cell where you put your formula.
Column Matching:
=SUM(INDEX(FILTER(D:E, TEXT(C:C, "MMMM") = E13),,MATCH(F12, D4:4, 0)))
You can use pivot table and group dates by year and month.

Filtering Values Produced by an ARRAYFORMULA

I am using an ARRAYFORMULA to extract unique values from a list of names and total up a second column for each of those names.
Here is some example data and the ARRAYFORMULA I am using
Example Data
ARRAYFORMULA in cell E3
=ARRAYFORMULA({{unique(B3:B11)},{sumif(B3:B11, (unique(B3:B11)),C3:C11)}})
What I would like to do is filter out those names where the total number of tokens is zero - i.e. I would like Peter to be filtered out of the list because he has a net total of zero Tokens.
[I'd also like to have Peter, and any others, displayed in a separate list, but I guess if you can help me crack this first part I can help myself crack the second part]
Is there a way I can achieve what I want with a single ARRAYFORMULA? Is there another (better) way to achieve the same result?
I've bashed my head against this for a while so would be grateful for any help
use:
=QUERY(QUERY({B3:C};
"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label sum(Col1)''");
"where Col2 is not null"; )
Query and Filter
=FILTER(QUERY(A2:B10,"select A, SUM(B) group by A"),QUERY(A2:B10,"select SUM(B) group by A") > 0)
You don't need an array formula. The FILTER on the outside of the QUERY takes care of our zero token problem. And the QUERY selects column A and SUM of B and returns the proper names and sums, so that there are no repeating names. We need a second identical QUERY for the FILTER to compare 0s against, Because our QUERY doesn't exist outside of the formula. Every reference you make to the QUERY requires you to perform the QUERY again.

Google Data Studio, how to get a sum of all Max or Min values

I am working with a data set where i have to get Min or Max for different text fields. My dataset can have thousands of rows so below is a simpler example. So I have 3 categories having multiple values and I can put this dataset in GDS to build a table where I select Category as dimention and Value as Max(Value) in metric.
Now I need to see the sum of all those values too. But like the pivot table in excel, the subtotal in GDS shows the Max out of all the max listed above. So instead of 65, it shows 30 in GDS. Is there a way I can get it to show the sum?
To reach the desired result you will need:
Make a data combination, not being necessary to insert a second base, just so that a current base is defined as a data combination.
In the combination use the Category dimension and define the Max Value metric. The combination is only necessary for the metric to be used in the table as a dimension (this is a property resulting from the combination of data).
Configure the table with the Category dimension and Include the metric with the Value sum option. Remember that now Value is the maximum value (as defined in the data combination).
Finally, display the Summary line. And the desired result is obtained

Resources