Why is my function in Google Sheet not working? [duplicate] - google-sheets

This question already has an answer here:
I get Formula parse error with all formulas
(1 answer)
Closed 4 months ago.
I have a spreadsheet with registrations for a Summer Camp. I want to filter the registrations based on location, in a new spreadsheet.
I have used the following code:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1BDv-P3Bx8kHLSEUILmFBMmSB502-LUkQ8oiw8BYaPyo/","Inschrijvingen!A2:W2800"),"SELECT * WHERE Col1 contains 'Amersfoort - Groep 1-2'")
It keeps on saying: error.
The second image is the main file with all registrations.

In the event your spreadsheet locale uses comma , instead of period . as decimal mark, you will have to use semicolons ; as formula argument separators, like this:
=query(
importrange("1BDv-P3Bx8kHLSEUILmFBMmSB502-LUkQ8oiw8BYaPyo"; "Inschrijvingen!A1:W");
"where Col1 contains 'Amersfoort - Groep 1-2' ";
1
)
You can choose the spreadsheet locale at File > Settings > Locale.

Related

Use dynamic created Query text as a Query formula in Google Sheets [duplicate]

This question already has answers here:
Stacking Multiple Arrays In Query/Lambda Function
(2 answers)
Closed 3 months ago.
First of all this is my first question here...
Ok, and now my problem:
I created a formula that generates a dynamic Query if you are searching for data in multiple sheets. I just write the names of the sheets in green field and it changes the Query.
The text for the Query is correct, but now I want this to by the actual formula in a cell to display the data.
If I use the = and add the cell with the Query text, it copy the text. I tried the INDIRECT formula, but it does the same.
How can I use a this dynamic text to be my Query to dispaly the data depending on the amount of names in the green field?
EDIT: As advised by user doubleunary (as mentioned, this is my first time), I'm going to rephrase the problem.
In an spreadsheet a manager imputs for every task the amount a worker has made. He creates an new sheet for each date and imputs the data for that day. Each day can have different rows of data. The boss wants a spreadsheet that display in one sheet all that has been done in the current month. I used Query because you can easy join data from multiple sheets and ignor the empty rows.
But the problem is, that every day a new sheet is added with a new "name" (date). And the easyest way I found tho make a dynamic Query, without the Boss to manualy edit the Query, was to create a text with TEXTJOIN formula, in witch he ony needs to enter the new "name" (date).
If there is a better was, please share, but it should not be in App Script if possible.
Thank you.
Easily you can't transform a text into a formula.
In this case, you should create the query formula and insert the ranges with Indirect function, like this:
=Query({Importrange(LINK,Indirect("'"&O4&"'!I38:S107"));Importrange(LINK,Indirect("'"&O5&"'!I38:S107"))},"Select * Where Col1 is not null",0)
If the formula you quote and the data sheets are all in the same spreadsheet file, you should not to use importrange() but indirect(), like this:
=query(
{
indirect(O4 & "!I38:S107");
indirect(O5 & "!I38:S107")
},
"where Col1 is not null",
0
)
In the event the row references such as I38:S107 change from time to time as well, you can put those references in a cell and refer to them the same way.
try (assuming url is same for all sheets):
=QUERY(LAMBDA(x, QUERY(REDUCE(SEQUENCE(1, 11), x,
LAMBDA(a, c, {a; IMPORTRANGE("url", c"!I38:S107")})),
"where Col1 is not null", 1))
(O4:INDEX(O:O, MAX((O:O<>"")*ROW(O:O)))), "offset 1", )
more examples: https://stackoverflow.com/a/74280310/5632629

Using query importrange but the not all results are returning [duplicate]

This question already has answers here:
Query is ignoring string (non numeric) value
(2 answers)
Google spreadsheets query() is replacing text with null for mostly numeric columns [duplicate]
(3 answers)
Closed 5 months ago.
I am using query import range to pull through data from another spreadsheet which works apart from when a different type of value is needed eg. 1234 or
12345 would return correctly but values like this RIFG_PI9926 or COHJRI4426 are left blank.
I am thinking it is a formatting issue but playing around with format settings it makes no difference.
My next thought is to use the query to force results in the original format to see if that will allow them to pull through correctly.
This is what I have so far but returns blanks
=QUERY(IMPORTRANGE("url","Sheet!A2:L"),"select Col4,Col7,Col1,Col2, Col3,Col9",0)
Col7 is the problematic column
When I recreated a similar test it worked fine with the above formula which makes me think that is is definitely the formatting in some way
this is a know QUERY issue occurring whenever you have a mixed dataset (numeric number with text strings)
sometimes it's enough just:
=QUERY({IMPORTRANGE("URL", "Sheet!A2:L")},
"select Col4,Col7,Col1,Col2,Col3,Col9 where Col7 is not null", 0)
but mostly you will need to convert your dataset into one type:
=INDEX(QUERY(TO_TEXT(IMPORTRANGE("URL", "Sheet!A2:L")),
"select Col4,Col7,Col1,Col2,Col3,Col9 where Col7 is not null", 0))

Google Sheets: Formula that returns same number of rows based on cell values [duplicate]

This question already has answers here:
Repeat whole row N times based on column value in Google Sheets
(2 answers)
Closed 4 months ago.
I have a list of users and a value that denotes how many times I want to return the user's name.
How do I set up a formula that helps me output this?
try:
=INDEX(QUERY(FLATTEN(IFERROR(SPLIT(REPT(A2:A&"×"; B2:B); "×")));
"where Col1 is not null"; ))

How to workaround Query with a mixed-data column? (google sheets) [duplicate]

This question already has answers here:
Query is ignoring string (non numeric) value
(2 answers)
Closed 5 months ago.
I have a simple Query that groups my data by months that was working fine before, but now that I've introduced a formula into my date column, it's not working anymore. (I'm guessing it's because the majority data in the column is now formulas instead of actual dates).
=Query(C5:L,"SELECT SUM(I) pivot MONTH(C)+1",1)
Is there a way for me to still get my intended Query data without removing my formulas in the date column? (Query formula is in M2)
Thank you in advance!
Link to sheet: https://docs.google.com/spreadsheets/d/1EpvLMboKJ0KeR7tTqBarF1AnAg3jelhKTkyBhwKNlK4/edit#gid=1335125620
Your formulas in Col C seem to be causing the issue since they're adding a blank space when there is no corresponding value in Col D:
=IF(D45=""," ",TIMESTAMP())
Instead, try:
=IF(D45="",,TIMESTAMP())

Trying to filter a query using data validation drop down - numerical options work, but not a combination of numbers/letters [duplicate]

This question already has answers here:
Query is ignoring string (non numeric) value
(2 answers)
Closed 5 months ago.
Here is a copy of my sheet https://docs.google.com/spreadsheets/d/1b7ofD9f02yKiIvGYfCBi_GdhkRtgTAoY2NpftJmZaDQ/edit?usp=sharing
So my query is on the front tab 'Overall' in D1
=query(Data!A1:G,"SELECT * WHERE 1=1 "&IF(A2="All Raids",""," AND A contains "&A2&" ") &IF(B2="All Classes",""," AND LOWER(B) = LOWER('"&B2&"') "),1)
On the datasheet, I have people listen in raids 1,2 and 3.. and it works fine. However, if I were to change a value to something like BWL1 or BWL2, it will not display.
I got this code from a youtube tutorial, so I don't understand it 100%, but basically the "a2=all raids","" part is just to remove any filters, then the remaining is filtered by my drop-down menus, &A2& and &B2&.
Any ideas?
I've tried using A CONTAINS "&A2" instead of A = "&A2&", I just cant figure out a workaround to where any value (numberical+lettered) listed in my Datasheet column A works.
Thank you in advance for your time, I hope this makes sense :)
That's a known issue with query() function: query() has trouble with mixed datatypes (numeric and text in column A). To avoid this you can convert column A to text. See if this formula works
=query({ArrayFormula(to_text(Data!A1:A)), Data!B1:G},"SELECT * WHERE 1=1 "&IF(A2="All Raids","", " AND Col1 contains '"&A2&"'") &IF(B2="All Classes",""," AND LOWER(Col2) = LOWER('"&B2&"') "),1)
Note that, because of the use of 'contains' when '1' is selected in A2, it will also show rows containing BWL1. If you don't want that, change 'contains' to '='.

Resources