Combining rows and columns of text using Sheets Queries - arrays

I'm trying to get to an array function that will select multiple rows and columns of data and present the data cleanly in a single cell. The data in the orange headed block has multiple rows (speakers) for each ID (sessions). The data in the blue block is the unique list of IDs (sessions) where I'm trying to get a formatted output. The ideal output would be (name) - (title) separated by cf/lf so multiple speakers will stack neatly in the same cell.
This gives an imperfect result with everything separated by dashes:
=TEXTJOIN(" - ",1,QUERY(A2:D17,"select B,C where A matches '"&F4&"' and D = 'T1'",0))
This should be closer to what I'm looking for but spits out a row mismatch error:
=QUERY({A:A,B:B&" - "&C:C&char(10),D:D},"select Col2 where Col1 matches '"&F4&"' and Col3 ='T1'",0)
And of course neither of these does this as an array and I'm trying to avoid having to maintain the sheet as sessions and speakers are added. I struggle with the intricacies of the query function so any help/instruction you can give would be very much appreciated!
Example Data

try:
=ARRAYFORMULA(TEXTJOIN(CHAR(10), 1, QUERY({A:A, B:B&" - "&C:C, D:D},
"select Col2
where Col1 matches '"&F4&"'
and Col3 ='T1'", 0)))

Related

How can I search a Google Sheet range row-by-row for matches to headers on another sheet and then add the first cell of the row under the header?

I have made a mockup of my google sheet here: https://docs.google.com/spreadsheets/d/1u5wlCjSdZOYdAs0V-WKGK8KYcZ7p80OJReTasTK3oH4/edit?usp=sharing. (My actual data consists of 90 columns and 60 rows.)
I want to search the range data!B2:M6 row-by-row for matches to formula!A1:L1 and if, for example, a match to formula!A$1 is found in the range data!B2:M2, I want data!$A2 to be placed in the first empty space in column A, etc.
Thank you so much for the assistance.
addendum: A complication it would be nice to solve as well. Some data is not an exact match, missing the final character (so it's Chemistr instead of Chemistry).
try:
=INDEX(IFERROR(HLOOKUP(A19:L19, TRANSPOSE(SPLIT(FLATTEN(QUERY(QUERY(SPLIT(FLATTEN(
IF(data!B2:M="",,data!B2:M&"×"&data!A2:A)), "×"),
"select max(Col2) where Col2 is not null group by Col2 pivot Col1"),,9^9)), " ")),
{2; 3; 4; 5; 6}, 0)))

Google Sheets: EXCLUDE hidden rows in query pulling unique data using indirect function

I have an Apps Script pulling every tab name in my Google Sheet into a list. I'm then using a Query to pull all unique Names (from a Name column) from each of those tabs, with the Indirect function.
There are currently hidden rows in each of the tabs (there are 15 tabs total). The Query I have is currently pulling the Names in those hidden tabs.
How do I tell the Query to pull all unique data EXCEPT the hidden rows? Here is the existing Query formula I have which is including hidden row data (I'm only including 2 tabs of data here to shorten the formula for this example):
=UNIQUE(QUERY({IF(B2="", {"","","",""}, INDIRECT(B2));IF(B3="", {"","","",""}, INDIRECT(B3))},"Select Col4 where Col4 is not null order by Col4 label Col4 'Names'",1))
The {"","","",""} is because I have INDIRECT formulas for future anticipated tabs which don't yet exist in the list of tabs, so I won't have to update the formula every time a new tab is added. For excluding the hidden data, I've looked into the SUBTOTAL formula but I'm having trouble applying it to this situation.
Here's a mock-up, smaller scale example of the sheet I'm working with. All of the names in the Names list on the Tabs tab that start with "Hidden" are in hidden rows on one of the tabs the query is pulling from. I want to exclude those Hidden names/rows from the query output.
Thanks in advance!
SUBTOTAL is the way but it does not work with arrayformula so you will need to drag it down into each row. see your sheet.
=UNIQUE(QUERY({
IF(B2="", {"","","","",""}, INDIRECT(B2));
IF(B3="", {"","","","",""}, INDIRECT(B3));
IF(B42="", {"","","","",""}, INDIRECT(B4))},
"Select Col4
where Col4 is not null
and Col5 = 1
order by Col4
label Col4 'Name'", 1))
also note the range change from A:D to A:E

How to get the source of an ARRAY formula combined with QUERY in Google Sheets

I have a Spreadsheet where each tab is a month (January, February, ..., December) and they have exactly the same structure.
In order to combine all the information in a single sheet I used an array:
={January!A5:Q;February!A5:Q;March!A5:Q;April!A5:Q;May!A5:Q;June!A5:Q;July!A5:Q;August!A5:Q;September!A5:Q;October!A5:Q;November!A5:Q;December!A5:Q}
But I wanted to filter the entries of each month based on some conditions, so I used the QUERY function:
=QUERY({January!A5:Q;February!A5:Q;March!A5:Q;April!A5:Q;May!A5:Q;June!A5:Q;July!A5:Q;August!A5:Q;September!A5:Q;October!A5:Q;November!A5:Q;December!A5:Q},"select * where Col3 = 'X'",0)
I get the desired result. The extra plus that I want to achieve is to identify the month at each line belongs, in other words, the sheet were the data is pulled. And I want to see that without adding columns or extra fields on the source sheets.
How do I do that?
try:
=ARRAYFORMULA(QUERY({
January!A5:Q, January!Z5:Z&"January";
February!A5:Q, February!Z5:Z&"February";
March!A5:Q, March!Z5:Z&"March";
April!A5:Q, April!Z5:Z&"April";
May!A5:Q, May!Z5:Z&"May";
June!A5:Q, June!Z5:Z&"June";
July!A5:Q, July!Z5:Z&"July";
August!A5:Q, August!Z5:Z&"August";
September!A5:Q, September!Z5:Z&"September";
October!A5:Q, October!Z5:Z&"October";
November!A5:Q, November!Z5:Z&"November";
December!A5:Q, December!Z5:Z&"December"}
"where Col3 = 'X'", 0))
where column Z is an empty column

Query with split in where clause

I'm trying to craft a Google Sheets query that outputs rows based on the left half of a split.
I'm using this in an employee status tracking sheet where my overview tab shows the last status update taken from the data tab (eventually)
This is what the overview tab will eventually look like. Note the number to the left of the employee name, I'm using this like an index.
This is where the data lives, there is an employee and multiple status updates. Note the numbers being used here as well. Each status update starts with the employee number "1" followed by a "-" then an incremental number.
It's easy enough to output all of the status updates, or a single status update, where I'm stuck is how to output only the updates that match the employee number.
=ArrayFormula(query({DataRange,to_text(DataRange)},"Select Col2, Col3, Col4 where Col2 ='"&"1-1"&"'",0))
Any ideas on how I can accomplish this?
-- or any suggestions for tacking this type of sheet in a different way?
try:
=ARRAYFORMULA(QUERY({DataRange, TO_TEXT(DataRange)},
"select Col2,Col3,Col4 where Col2 ='1-1'", 0))
and make sure that 1-1 is formatted as Plain text not Date

SSRS 2012 Set a chart series legend from another dataset based upon the column name

I'm back with a question about the feedback card application.
For my final chart, I have a stored procedure with a dynamically built pivot query that has columns named Col1, Col2, Col3, ... Col 30, CardDate and FormattedCardDate. The columns either have data for a specific card feedback type (up to 30), as selected on the report setup form.
I also have another dataset with the display titles for the selected feedback types with the following columns Feedback ID, DisplayTitle and ColName.
I have tried to use a lookup for the legend like:
=Lookup(Fields!Col1.UniqueName, Fields!ColName.Value, Fields!DisplayTitle.Value, "dsGetLabels")
With the following data:
ID DisplayTitle ColName
================================================
1 Room Cleaned Col1
4 Kitchenette Counter Col2
...
But it only dislpays Col1 for Col1, not "Room Cleaned" as in the column name dataset.
How do I make the lookup work? Barring that, how can I add the correct column names to my stored procedure, but still access the data?
As an aside, I can pass the correct column names to the SSRS Chart as a parameter, but how would I display them as a legend?
If your main dataset is returning only a few hundred or a few thousand rows then you should see no difference between adding four extra fields to your main dataset, however, your type dataset solution is just as valid and would be ideal for super huge datasets.

Resources