DGET with array constant as criteria parameter with a blank element - google-sheets

If I have the following table:
\ || A | B | C | D | E | F |
_______________________________________
1 || H1 | H2 | H3 | H4 | 10 | 20 |
2 || 10 | AA | .2 | 70 | 70 | 100 |
3 || 10 | BB | .3 | 80 | | |
4 || 20 | CC | .4 | 90 | | 10 |
5 || 20 | DD | .5 | 100 | | CC |
6 || | | | | | |
(*All workings examples are in Google Docs)
This works:
=DGET(A1:D5,"H3",{A1:D1;E1,E3,E4,E2})
RESULT = 0.2
But I'm looking for a way to have a blank element in the constant array I'm using as the criteria without referencing a blank cell. I need the blank elements as otherwise DGET treats them as criteria to be evaluated.
Something like this:
=DGET(A1:D5,"H4",{A1:D1;E1,#BLANK,#BLANK,E2})
Where #BLANK is whatever magic makes google docs treat the element as empty.
I know that I can do:
=DGET(A1:D5,"H3",{A1,D1;E1,E2})
And just limit the number of columns in the criteria, but I'd like to specify the entire header set in the constant and just choose the columns I want specified.
For instance if I wanted something like this:
=DGET(A1:D5,"H3",{A1:D1;F1,F3,F3,F2;F4,F5,F3,F3})
RESULT = 0.5
But as this:
=DGET(A1:D5,"H3",{A1:D1;F1,#BLANK,#BLANK,F2;F4,F5,#BLANK,#BLANK})
In addition to the primary question of how to set an empty element, I'm curious if there is a way to perform a similar lookup in Excel. LOOKUP functions do not appear to support filtering on multiple criteria and the Database functions don't support arrays for defining criteria (only a cell range).

I believe that the #BLANK you're looking for is:
""
And, No. Excel does not support such sophisticated arrays.

Related

Create column taking number of values from one column and actual value from another column

I have two columns, A and B, where A contains the number of values for corresponding value in B. I want to create column C that contains the number of values from A but with the value from B. So for example:
| A | | B |
| 2 | | 40 |
| 3 | | 60 |
Should produce:
| C |
| 40 |
| 40 |
| 60 |
| 60 |
| 60 |
So 2 of 40 and 3 of 60. This could be in memory (I only want to use C in a formula, don't really need it as an actual column) or as its own column.
Give a try on below formula-
=ArrayFormula(TRANSPOSE(SPLIT(TEXTJOIN("#",TRUE,REPT(B1:B2&"#",A1:A2)),"#")))

Influx: doing math the same fields in different groups

I have InfluxDB measurement currently set up with following "schema":
+----+-------------+-----------+
| ts | cost(field) | type(tag) |
+----+-------------+-----------+
| 1 | 10 | 'a' |
| 1 | 20 | 'b' |
| 2 | 12 | 'a' |
| 2 | 18 | 'b' |
| 2 | 22 | 'c' |
+------------------+-----------+
I am trying to write a query that will group my table by timestamp and get a delta between field values of two different tags. If I want to get delta between tag 'a' and tag 'b', it will give me following result (please not that I ignore tag 'c'):
+----+-----------+------------+
| ts | type(tag) | delta_cost |
+----+-----------+------------+
| 1 | 'a' | 10 |
| 2 | 'b' | 6 |
+----+-----------+------------+
Is it something Influx can do or am I using the wrong tool?
Just managed to answer my own question. While one of the obvious ways would be performing self-join, Influx does not support joins anymore. We can, however, use nested selects in a following format:
SELECT MEAN(cost_a) - MEAN(cost_b) as delta_cost
FROM
(SELECT cost as cost_a, tag, tablename where tag='a'),
(SELECT cost as cost_b, tag, tablename where tag='b')
GROUP BY time(60s)
Since I am getting my data every 60 seconds anyway, and I have a guarantee of just one point per tag per 60 seconds, I can use GROUP BY and take MEAN without any problems

How to copy a whole row as a template and replace one columns value in Google Sheets

I have a sheet which im using to build product data. I need to handle some custom SKU's and id like to have them stored in a string like "XYZ,ABC,FGH" in an alternate sheet.
The generic products are generated in the other sheet for various sizes automatically. I would like on the end of this list to be able to take one of these automatic rows as a template and replace the SKU with one of the custom SKU's if they exist in the other config sheet.
So for example:
SKU'S | Name | Width | Height | Weight | Quantity
--------------------------------------------------
PARENT| X | 10 | 20 | 100 | 0
M1 | X | 10 | 20 | 100 | 1
M2 | X | 10 | 20 | 100 | 2
M3 | X | 10 | 20 | 100 | 3
M4 | X | 10 | 20 | 100 | 4
M5 | X | 10 | 20 | 100 | 5
Then append:
ABC | X
XYZ | X
FGH | X
Keeping the existing columns the other products use.
The X's are just a representation for the other columns I want to copy (ive added some further columns as example data). The only thing I want to change is the SKU. Its a duplicate apart from the SKU (which I want to replace) and the Quantity. The consistent one to copy and use as the template would be the row with PARENT as the SKU.
The result is to just be a new row underneath M5 row. These are additional rows to just be tagged onto the end except for a change in the SKU.
The import is a lot of duplication to the database which is the product attributes like width, height, depth, weight, etc. This is set in a sheet I made with the name VARS. So I would create a simple field in VARS for 'Custom Additional SKUs' in say VARS!$B$10 with the value 'ABC,XYZ,FGH'. These would then use the same columns as the SKU's in say a sheet called INVENTORY.
The end result would be something like:
SKU'S | Name | Width | Height | Weight | Quantity
--------------------------------------------------
PARENT| X | 10 | 20 | 100 | 0
M1 | X | 10 | 20 | 100 | 1
M2 | X | 10 | 20 | 100 | 2
M3 | X | 10 | 20 | 100 | 3
M4 | X | 10 | 20 | 100 | 4
M5 | X | 10 | 20 | 100 | 5
ABC | X | 10 | 20 | 100 | 0
XYZ | X | 10 | 20 | 100 | 0
FGH | X | 10 | 20 | 100 | 0
Final solution based on feedback to help others.
Based on the great input from pnuts I went with the following in column A underneath:
=sort(transpose(split(VARS!A1,",")),1,TRUE)
In column B:
=IF(ISBLANK(A7),"",QUERY(SKU!A2:F2,"select B,C,D,E,F",0))
Works like a charm!
Maybe try:
=sort(transpose(split(NamedRange1,",")),1,TRUE)
and next to the above something like:
=QUERY(SKU!A:F,"select B,C,D,E,F where A='PARENT'",0)
copied down to suit.

Matching cell and returning average of multiple columns

I have a Google Sheets with the following sheets:
Heroes
A | B | C | D | E
-------------------------------------------------------
The Flash | 5 | 10 | 4 | 82
Jesse Quick | 0 | 2 | 5 | 4
Quicksilver | 1 | 3 | 12 | 2
Kid Flash | 10 | 9 | 7 | 17
Calc
A | B
-------------------------------------------------------
The Flash |
Quicksilver |
I want to match column A in Calc and return the average value of column B to E from Heroes.
So based on the date above, I want Calc should look like this:
A | B
-------------------------------------------------------
The Flash | 25,25
Quicksilver | 4,5
I had this function in Calc:
=AVERAGEIF(Heroes!A:A;B2;Heroes!B:B))
changed to:
=AVERAGEIF(Heroes!A:A;B2;Heroes!B:E))
but this only returns 5 for The Flash and 1 for Quicksilver.
You can try this
=AVERAGE(ARRAYFORMULA( VLOOKUP(A5,A12:E13,{2,3,4,5},FALSE)))
Where A12:A13 refers to HEROES
and A5 refers to Cal
https://docs.google.com/spreadsheets/d/1AEbci4BN8SyYcmpfOELGRQC4wpRqPn-dUoZy5GdkTyM/edit?usp=sharing
For the Flash have: =AVERAGE(Heroes!B1:E1)
For Quicksilver have: =AVERAGE(Heroes!B2:E2)
Using this pattern allows you to get the average of all the Cells in the column of the hero you want. Remember you have to specify the cells, right now you are specifying the whole columns of B-E, when you just want the row of each hero.

Query completed with an empty output

https://docs.google.com/spreadsheets/d/1033hNIUutMjjdwiZZ40u59Q8DvxBXYr7pcWyRRHAdXk
That's a link to the file in which it is not working! If you open it, go to sheet named "My query stinks".
The sheet called deposits has data like this in columns A (date), B (description), and C (amount):
+---+-----------+-----------------+---------+
| | A | B | C |
+---+-----------+-----------------+---------+
| 1 | 6/29/2016 | 1000000044 | 480 |
| 2 | 6/24/2016 | 1000000045 | 359.61 |
| 3 | 8/8/2016 | 201631212301237 | 11.11 |
+---+-----------+-----------------+---------+
The sheet "My Query Stinks" has data in columns A (check number), B (failing query) and C (amount):
+---+-----------------+------+--------+
| | A | B | C |
+---+-----------------+------+--------+
| 1 | 1000000044 | #N/A | 480 |
| 2 | 1000000045 | #N/A | 359.61 |
| 3 | 201631212301237 | #N/A | 11.11 |
+---+-----------------+------+--------+
In Column B on My Query Stinks, I want to enter a query. Here's what I'm trying:
=query(Deposits!A:C,"select A where A =" & A2)
For some reason, it returns "#N/A Error Query completed with an empty output." I want it to find that 1000000044 (the value in C4) matches 1000000044 over on Deposits and return the date.
Try
=query(Deposits!A:C,"select A where B ='" &A2&"'")
Explanation
Values like 1000000044 in Column B of the Deposit sheet and Column A of My Query Stinks sheets are set as text (string) values, so they should be enclosed on single quotes (apostrophes) otherwise QUERY think this values are numbers or variable names.
Try this:
=query(Deposits!A:C,"select A where B = '"&A2&"' LIMIT 1")
You'll need LIMIT 1 as you have multiple deposits for the same value in your second column.
Another solution for this problem could be to replace '=' with 'contains':
=query(Deposits!A:C,"select A where B contains '" &A2&"'")
Simple, but this error cost me half a morning.

Resources