Query Sheets sum if NOT match any values in this other range - google-sheets-query

Would like to produce results that are contingent on any of the list of values in one range, not appearing in my other range!
#jpv had a great solution for the OPPOSITE of what i want, in this post: https://stackoverflow.com/a/54763013/12848172
Thanks!

Related

Google script custom function for different column [duplicate]

I'm trying to do a couple of different things with a spreadsheet in Google and running into some problems with the formulas I am using. I'm hoping someone might be able to direct me to a better solution or be able to correct the current issue I'm having.
First off all, here is a view of the data on Sheet 1 that I am pulling from:
Example Spreadsheet
The first task I'm trying to accomplish is to create a sheet that lists all of these shift days with the date in one column and the subject ("P: Ben" or S: Nicole") in another column. This sheet would be used to import the data via a CSV into our calendar system each month. I tried doing an Index-Match where it used the date to pull the associated values however I found that I had to keep adjusting the formula offsets in order to capture new information. It doesn't seem like Index-Match works when multiple rows/columns are involved. Is there a better way to pull this information?
The second task I am trying to accomplish is to create a new tab which lists all the dates a specific person is assigned too (that way this tab will update in real time and everyone can just look at their own sheet to see what days they are on-call). However, I run into the same problem here because for each new row I have to change the formula to reflect the correct information otherwise it doesn't pull the correct cell when it finds a match.
I would appreciate any and all information/advice on how to accomplish these tasks with the formula combination I mentioned or suggestions on other formulas to use that I have not been able to find.
Thanks in advance!
Brandon. There are a few ways to attack your tasks, but looking at the structure of your data, I would use curly brackets {} to create arrays. Here is an excerpt of how Google explains arrays in Sheets:
You can also create your own arrays in a formula in your spreadsheet
by using brackets { }. The brackets allow you to group together
values, while you use the following punctuation to determine which
order the values are displayed in:
Commas: Separate columns to help you write a row of data in an array.
For example, ={1, 2} would place the number 1 in the first cell and
the number 2 in the cell to the right in a new column.
Semicolons: Separate rows to help you write a column of data in an array. For
example, ={1; 2} would place the number 1 in the first cell and the
number 2 in the cell below in a new row.
Note: For countries that use
commas as decimal separators (for example €1,00), commas would be
replaced by backslashes () when creating arrays.
You can join multiple ranges into one continuous range using this same
punctuation. For example, to combine values from A1-A10 with the
values from D1-D10, you can use the following formula to create a
range in a continuous column: ={A1:A10; D1:D10}
Knowing that, here's a sample sheet of your data.
First Task:
create a sheet that lists all of these shift days with the date in one
column and the subject ("P: Ben" or S: Nicole") in another column.
To organize dates and subjects into discrete arrays, we'll collect them using curly brackets...
Dates: {A3:G3,A7:G7,A11:G11,A15:G15}
Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}
This actually produces two rows rather than columns, but we'll deal with that in a minute. You'll note that, because there are two subjects per every one date, we need to effectively double each date captured.
Dates: {A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15}
Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}
Still with me? If so, all that's left is to (a) turn these two rows into two columns using the TRANSPOSE function, (b) combine our two columns using another pair of curly brackets and a semicolon and (c) add a SORT function to list the dates in chronological order...
=SORT(TRANSPOSE({{A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15};{A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}}),1,TRUE)
Second Task:
create a new tab which lists all the dates a specific person is
assigned too (that way this tab will update in real time and everyone
can just look at their own sheet to see what days they are on-call).
Assuming the two-column array we just created lives in A2:B53 on a new sheet called "Shifts," then we can use the FILTER function and SEARCH based on each name. The formula at the top of Ben's sheet would look like this:
=FILTER(Shifts!A2:B53,SEARCH("Ben",Shifts!B2:B53))
Hopefully this helps, but please let me know if I've misinterpreted anything. Cheers.

Find Row Where Sum is Reached from Single Joined Column (not a range of cells)

I'm trying to run a formula to identify in which row a total sum is reached.
I've been able to do that calculation when I have an entire range of cells to work with, however, I'm doing a filter / join calculation because I need to do this from an individual row with all the data instead of an entire range of cells.
Here is an example google sheet (EDITABLE - feel free) where you can see the range and working formula (both below). Help getting this from the single-cell versions on the top would be very helpful. The error I get with both row() & index() formulas is that the "argument must be a range".
If there's another way to do this besides the single-cell I had that doesn't require referencing the range (e.g. using FILTER) then I'm open to it.
My desired result is to be able to pull the get the second column (date) at the point when the sum is reached (can be via the INDEX & MATCH formula I used or an alternative). This will tell me the earliest date that feeds into the desired sum.
Yes unfortunately you can't do that trick with SUMIFS to get a running total unless the column being totalled is an actual range.
The only approach I know is to multiply successive values by a triangular array like this:
1 0 0 ...
1 1 0 ...
1 1 1 ...
so you get just the sum of the first value, the first 2 values, then 3 values up to n.
This is the formula in F5:
=ArrayFormula(match(E14,mmult(IF(ROW(A1:INDEX(A1:ALL1000,COUNT(split(A5,",")),COUNT(split(A5,","))))>=
COLUMN(A1:INDEX(A1:ALL1000,COUNT(split(A5,",")),COUNT(split(A5,",")))),1,0),TRANSPOSE(SPLIT(A5,",")))))
And the formula in F6 is just
=to_date(INDEX(TRANSPOSE(SPLIT(B5,",")),F5,1))
EDIT
You might have guessed that the above formula was adapted from Excel, where you try to avoid volatile functions like Offset and Indirect.
I have realised since posting this answer that it could be improved in two ways:
(1) By using Offset or Indirect, thus avoiding the need to define a range of arbitrary size like A1:ALL1000
(2) By implying a 2D array by comparing a row and column vector, rather than actually defining a 2D array. This would give you something like this in F5:
=ArrayFormula(match(E14,mmult(IF(ROW(indirect("A1:"&address(COUNT(split(A5,",")),1)))>=
COLUMN(indirect("A1:"&address(1,COUNT(split(A5,","))))),1,0),TRANSPOSE(SPLIT(A5,",")))))
which could be further simplified to:
=ArrayFormula(match(E14,mmult(IF(ROW(indirect("A1:A"&COUNT(split(A5,","))))>=
COLUMN(indirect("A1:"&address(1,COUNT(split(A5,","))))),1,0),TRANSPOSE(SPLIT(A5,",")))))

What is the function of this =COUNTIF(Data!B:B,Data!B:B&"") Excel Formula?

I'm trying to convert excel formula to mysql syntax. I can't understand what is the function of this formula:
=IF(G1="ALL",SUMPRODUCT((Data!I:I>=Dashboard!C4)*(Data!I:I<=Dashboard!C5)*(Data!P:P="ON-TIME")*(Data!B:B<>"")/
COUNTIF(Data!B:B,Data!B:B&"")),
SUMPRODUCT((Data!D:D=G1)*(Data!I:I>=Dashboard!C4)*(Data!I:I<=Dashboard!C5)*(Data!P:P="ON-TIME")*(Data!B:B<>"")/
COUNTIF(Data!B:B,Data!B:B&"")))
Can someone explain what is the function of this COUNTIF(Data!B:B,Data!B:B&"")?
Excel COUNTIF:
Syntax: =COUNTIF (range, criteria)
Description: COUNTIF is a function to count cells that meet a single criteria. COUNTIF can be used to count cells with dates, numbers, and text that match specific criteria. The COUNTIF function supports logical operators (>,,=) and wildcards (*,?) for partial matching.
Range is obvious, but the criteria includes two Excel hacks that can be a bit obscure:
& before a cell reference will construct a text string.
see COUNTIFS with wildcard characters (its still not 100% clear)
{range}&"" means to include empty cells as a value in the computation, because normally empty cells will be skipped automatically.
Criteria with a range will cause a spill range evaluation
Note: I can't find a good reference on this...
Visually in excel this formula will be repeated for each cell in the range
COUNTIF(Data!B:B,Data!B:B&"") is saying:
Count the values in the range Data!B:B that match this cell's value, if this cell is empty, count all the empty cells in the range.
But do this for every cell in the range as well, returning a matrix of values for each cell in the range, this is the spill range bit.
It might be easier to demonstrate it, see this example:
- Range: A1:B3
- Criteria: Count all matches of the same value in the range, for each cell
- Column E shows the results of the individual formula displayed in column D
- Column I shows the results of the individual formula displayed in column H
- D5 shows the single formula that has a spill range the size of the source range matrix
- For comparison, H5 the formula that has a spill range the size of the source range matrix
Note the results in J5, without the &"" the blank cell will not be included in the count results.
In this example we can see how you could extrapolate the formula into individual cells, meaning you would have to enter the formula multiple times, but when you try to set that formula in the first cell (D1) and use the formula drag caret drag that formula to the other cells, it will also transpose the ranges, which is not what you want, see this:
Especially when your range is large, putting a range in the criteria, creating a spill range means that we only have to define the formula once and excel will effectively transform that into individual formulas for each cell in the range.

force empty cells to end of sorted column

I want to sort a sheet by a column that has strings in it. I'm populating the sheet by putting a query based on an import range in the first cell. It seemed best if I did the sort as part of the query, order by Col6. This places all the empty rows at the top unless I sort descending, which I do not want to do. I found the opposite of what I want to do in the question titled "sort-empty-cells-to-top"
The answer there gets the values of the sheet's data range and works with the values array, then puts it back into the range. How would I change the compare function to force empty cells to the bottom in an ascending sort?
This might do what you want. You may have to build a helper column with somrthing in each row you want to return (like my Col7 (column G)).
=query(query(Sheet1!A1:G,"select * order by F "),"Select * where Col7 <>''")

Drill Down on a Zero Value in an SSRS Bar Chart

I have a bar chart in SSRS that does legitimately produce zero values. Is it possible in SSRS to drill down on the zero values like you can with non-zero values? The action on the data series works great for all values other than zero.
What about a range chart? The range chart takes dates as values, so depending on how your data is grouped as long as they have a date associatead with it they will map out and then you can drill through. You might even be able to add dates yourself.
The only thing you have to watch out for it that the range chart takes in a range of dates so you need two. But you can always do a dateadd aggregate function to produce another column and that could be your second date value.
Let me know if this helps, Cheers!
The zero values still have a clickable link, it's right on the axis (or at zero). Not easy to find or to click but it does work.