I have a table with data that I want to run a QUERY from.
In the output tab I need just one column from the data tab, but also I have 3 empty columns in the output tab, that are not in the data tab, that I need to be filled automatically, based on conditions, preferably with the QUERY.
I am using a simple QUERY formula to load the data that I have in the source tab to the output tab.
=QUERY('Source'!$A$1:$X, "SELECT A WHERE F IS NOT NULL", 1)
The issue is that I can not have any other formulas in the output sheet, rather than the QUERY itself, as some issues arise when exporting Google Sheet that contains formulas to .CSV.
Regardless if the above is true or not, these are the rules...
This is the output that I need to have:
+---------+------------+-------------------+-----------------+
| Country | Researched | Status | Reason |
+---------+------------+-------------------+-----------------+
| UK | TRUE | In Progress | |
+---------+------------+-------------------+-----------------+
| US | TRUE | Unable to Proceed | Not a UK member |
+---------+------------+-------------------+-----------------+
Column 1 is what the QUERY extracts from the source.
Columns 2 to 4 are the ones that I need to create with the QUERY.
The value of each cell in those columns depends on column 1, except for column 2 that needs to have the value "TRUE" for each record.
Is it possible to implement multiple conditions in the QUERY itself, that will fill the empty columns in the output tab, based on conditions?
=QUERY({QUERY(Source!$A$1:$X,
"select A, 'TRUE'
where F is not null
label 'TRUE' 'Researched'", 1),
QUERY(ARRAYFORMULA(IFERROR(VLOOKUP(
QUERY(Source!$A$2:$X,
"select A
where F is not null", 0),
{"UK", "In Progress", ""}, {2, 3}, 0),
{"Unable to Proceed", "Not a UK member"})),
"select *
label Col1 'Status', Col2 'Reason'", 0)}, , 0)
Related
I have my current query below;
=QUERY({Source_1!B2:I;Source_2!B2:I;Source_3!B2:I},"select * where Col3 is not null",0)
I want to have all my data be combine to one to "All_Sheet" tab it works so far.
Now I need in Col A of my tab "All_Sheet" be included to all rows the Sheet Name like Source_1, Source_2 and so on.
Try this:
Add a calculated column
First build a range that contains the sheet name you want to reference. I did it by concatenating a range that is empty and the sheet name:
{N2:N&"Sheet1",Source_1!B2:I}
The above by itself won't work, because it needs to be told that it is an array. So we wrap it in ARRAYFORMULA():
ARRAYFORMULA({N2:N&"Sheet1",Source_1!B2:I})
Which gives a range that looks like this:
Then build up the rest of your query like this:
Sheet 1 | B2 Value | C2 Value | D2 Value | ...
Build our Query
Take the above and build up your multiple ranges and complete your query. Linebreaks for readability
=QUERY(
ARRAYFORMULA(
{
N2:N&"Sheet1",Source_1!B2:I;
N2:N&"Sheet2",Source_2!B2:I;
N2:N&"Sheet3", Source_3!B2:I
}),
"select * where Col3 is not null",0)
I have 2 tabs needing worked with. The first tab, market_pull has a function that pulls information from EVE Online's ESI and sorts the information into several columns:
duration | is_buy_order | issued | location_id | min_volume | order_id | price | range | type_id | volume_remain | volume_total
The second tab, bulk_market_data sorts the information into several columns:
Citadel ID | Item Id | Item Name | Volume Ea | Qty Available | Lowest Price | Total Volume | Jita Sell | ISK Difference | % Difference
I need help with the bulk_market_data tab. I need to use the Item Id column from bulk_market_data as a criteria to compare to market_pull the column type_id pull the MIN value from the corresponding row in the price column.
I need to do essentially the same thing except I need to use the Item Id column from bulk_market_data as a criteria to compare to market_pull the column type_id pull the total SUM value from the all the corresponding rows in the volume_remain column.
I'm using array formulas because in the bulk_market_data tab there is about 10,000 rows and when I had a formula in every row for every column the sheet slowed down drastically. Thank you for your time and HERE is a sample spreadsheet with the concept.
use in F4:
=ARRAYFORMULA(IFNA(VLOOKUP(C4:C, QUERY({market_pull!C4:C, market_pull!J4:K},
"select Col2,sum(Col3) where Col2 is not null and Col1 = FALSE group by Col2"), 2, 0)))
use in G4:
=ARRAYFORMULA(IF(C4:C="",,IFNA(VLOOKUP(C4:C, SORT(QUERY({market_pull!C4:J},
"select Col8,Col6 where Col1 = FALSE"), 1, 1, 2, 1), 2, 0), 0)))
use in H4:
=ARRAYFORMULA(IF(C4:C="",,ROUNDUP(IF(
E4:E1004*F4:F1004=0,,E4:E1004*F4:F1004), 1)))
I have 1 mastersheet in which I want to add all the data from 2 other sheets if column J (Col10) is empty.
This formula does not work:
=query({'BXL | hair salon | Export'!1:1000; 'BXL | Bike shop | export'!1:1000}, "select * where Col10 is null", 1)
In this case I only get the results from the first sheet. (BXL | hair salon)
The opposite, where I do the following (and add all the data where column j is not null) does work (but it's ofc not what I need):
=query({'BXL | hair salon | Export'!1:1000; 'BXL | Bike shop | export'!1:1000}, "select * where Col10 is not null", 1)
How is this possible? Is there something about null i do not understand?
Ok, I found the answer.
Not null also takes the cells of the completely empty rows. When I scrolled way (way) down, I could see the results.
I fixed it for now like this:
=query({'BXL | hair salon | Export'!1:1000; 'BXL | Bike shop | export'!1:1000}, "select * where (Col10 is NULL and Col2 is not null)", 1)
As every column B has data when it's a not empty row, this filters out the entirely empty rows.
I have a column with data (movie genres in this case) that looks like this:
| Drama |
| Action, Drama |
| Action, Adventure, Drama |
I am trying to get the most frequent occurring value, which is 'Drama' in this case.
I came up with the following formula as a beginning but even that doesn't do what I want it to do.
ARRAYFORMULA(COUNT(UNIQUE(TRIM(SPLIT(A1:A3, ",")))))
This returns 0 but I want it to return 3 in this case and then find the most frequent unique value. Any ideas?
Basic case
=QUERY(index(if({1,1},TRANSPOSE(SPLIT(JOIN(", ",FILTER(A:A,A:A<>"")), ", ")))),
"select Col1, count(Col2) group by Col1 order by count(Col2) desc")
Notes:
transpose + split + join is to get the line with all values
index + if({1,1}... is to double the column, for query to work. See this trick on sample file.
query is to select the most frequent values on the top.
Get only top value
use index:
=index (original_formula, 2, 1)
First I will explain what I am trying to achieve
I have a list with several columns and rows, like this
| a | b | c
-----------------
1 | f1 | 4 | f
2 | f2 | 9 | k
3 | f3 | 1 | x
In another column outside the list I want to write a list with variable size, that contains values of column 'a'.
This list would be for a query like this (suppose that I write the variable list in the column 'd')
=QUERY(A2:D3,"SELECT a, b, c WHERE A IN D")
I think the problem is that I can not use the IN operator from sql
Is there a way to achieve this? The most important part is that I want to write manually a list with variable size for the query?
Thy this formula, in cell E1:
=FILTER(A:C,REGEXMATCH(A:A,JOIN("|",FILTER(D:D,D:D<>""))))
FILTER formula can take any array as condition parameter. REGEXMATCH + JOIN with pipe | will match true when any text from D matches text from A.
This formula is good for one more reason, you may use it as source for further query, like this: =query(my_formula, "select Col1, Col3 where Col2 > 0")