Fusion tables OR is not supported [duplicate] - google-fusion-tables

According to https://developers.google.com/fusiontables/docs/developers_reference OR operations are not allowed as part of filter conditions. So I'm trying to come up with a creative way to solve the following:
I have a fusion table backed google map with hundreds of places and want to filter it to only places that have 'tags' or a 'title' containing a search parameter.
Ideally I could just use the following as my filter condition:
tags CONTAINS IGNORING CASE 'searchterm' OR title CONTAINS IGNORING CASE 'searchterm'
But the fusion table API simply doesn't allow it. So what to do? Make 2 separate queries, then filter out the duplicates? That means I can't use the nice FusionTablesLayer pre-rendered tile functionality.
What would you do?

A possible answer is to pre-render the data within the table. Essentially add another column which is an aggregate of tags and title. Then I only need to query the one 'tags_or_titles' column. Of course this means more data munging beforehand when I export the data into the fusion table and doesn't feel so nice and clean...

How about adding a column to your table called "Show_In_Results",
then running two separate queries to update that column for each row of data based on whether the search term is found in the specific column or not.
UPDATE 'table_id'
SET Show_In_Results = 1
UPDATE 'table_id'
SET Show_In_Results = 1
WHERE tags CONTAINS IGNORING CASE 'searchterm'
UPDATE 'table_id'
SET Show_In_Results = 1
WHERE title CONTAINS IGNORING CASE 'searchterm' and Show_In_Results <> 1
Then when you render your map layer:
SELECT 'columns' FROM 'table_id' WHERE Show_In_Results = 1

Related

Google Sheets: Many to Many Table Join

I am trying to create a sheet to determine the amount of overlapping hours for employees.
I have one table with timeclock data for the Employees.
Table 1
And another with timeclock data for their Support Staff.
Table 2
This is the desired output. Each row from table A has all the date matches from table B. From here I would compute the number of overlapping hours in the final column and then roll that up into another sheet.
Table 3, Desired Output
(apologies for image links, I can't post inline images yet)
Sample sheet here Please let me know if you have any ideas for me!
I know its a combination of QUERY, ARRAYFORMULA, FILTER and more but I just can't find the right combo.
Here's a way of doing this type of join using only built-in functions:
=arrayformula(lambda(employee,support,
lambda(datecomp,
lambda(rows,
{vlookup(index(rows,,1),{row(employee),employee},sequence(1,columns(employee),2),false),
vlookup(index(rows,,2),{row(support),support},sequence(1,columns(support),2),false)})(
split(filter(datecomp,datecomp<>""),"|")))(
flatten(if(index(employee,,1)=transpose(index(support,,1)),row(employee)&"|"&transpose(row(support)),))))(
Employee!A1:D6,Support!A1:E5))
There's a lot going on here, but the basic idea is that we are comparing the date columns of each table against each other in a 2D IF array, and where the dates match we are obtaining the row index of each table. After some manipulations we can use these row indexes on each table in two side-by-side VLOOKUPs to obtain the joined table.
DMac,
I wrote myself a QUERY replacement custom function that uses real SQL select syntax.
For your data it looks something like (You need a tab called employee and a tab called support for this to work) :
=gsSQL("select * from employee full join support on employee.date = support.date")
See my test worksheet: (line 164 on gsSqlTest sheet)
https://docs.google.com/spreadsheets/d/1Zmyk7a7u0xvICrxen-c0CdpssrLTkHwYx6XL00Tb1ws/edit?usp=sharing
You need to add one Apps Script file to your sheet to give you the custom function:
https://github.com/demmings/gsSQL/blob/main/dist/gssql.js
For more help using more features see:
https://github.com/demmings/gsSQL
For example, changing the column titles, it would be like:
select employee.name as name .... (rest of your select).

When using QUERY, how can I make it so that data moves together when using filter?

I am creating a tool for a video game I play.
Link to the example spreadsheet (Please make a copy to edit so that this copy stays intact for additional helpers).
Sheet 1 is “Choose Owned”. It contains a list of all of the champions available in the game and includes their attributes.
Column A contains checkboxes. Checking a checkbox indicates that the user owns that champion, and brings it to Sheet 2.
Sheet 2 is called “Owned”. It contains a list of the champions checked off in “Choose Owned” (aka the champions the user owns). “Owned” includes the champion attributes too, as first seen in “Choose Owned”.
Beyond those same attributes, “Owned” contains 8 additional columns.
These columns are from Columns G:N and are labeled ‘Level’, ‘Rank’,
‘Ascension Lvl’, and ‘Team Label(s)’ (‘Team Label(s)’ takes up
columns J:N). This data is all unique information and requires the
user to input the information themselves depending on their
champions.
Because there are so many champions, I want the user to be able to use the Filter function in “Owned” so they can easily locate the champion they need or sort the table however they wish.
However, because I use the QUERY function to get the data from “Choose Owned”, the Filter function tends to break. The most obvious error comes when you try to sort A-Z or Z-A; this simply cannot be done. I was fine with this, and have even included a note at the top telling the user to avoid sorting alphabetically.
Everything else works correctly until the user tries to add a new champion from “Choose Owned”. When the champion is added to “Owned”, the additional, unique data in columns G:N go out of order because they don’t move with their original champions.
Example:
I choose my champions. These champions are copied to “Owned”.
I pick their relative data in columns G:N.
A few days later, I obtain new champions and check them off in “Choose Owned” so they are added to “Owned”. However, when I do this, the champions stay in the same order as they are in “Choose Owned”, and columns G:N do not move with their champions so now, that information is with the wrong champion.
I want the additional data (G:N) to move with their champions when the table is edited due to champions being added. Or, in other words, I want those columns to stay linked to the first columns.
If there is a different way to achieve all of this like if I have to use a function other than QUERY, that is fine!
Please share any solutions you may have. I would prefer to not use a script but will consider the idea if it works.
this is a common issue within Google Sheets and it's solvable in 2 ways:
either by introducing a common value (unique ID) and then linking the manual input to query and aligning it by ID
or easier approach in your case - using timestamp/linear ID so every new entry would be added to the bottom and then the query would be sorted based on this order.

Reorganizing Google Sheets data dynamically

I'm currently working with Google Sheets to import data from Contact Form 7 in Wordpress. All the data is coming over fine, but I wanted to see about formatting it in more user friendly fashion. I've simplified the example a bit, but the gist of the form I have created allows the user to request multiple versions of a graphic file with different wording as needed, up to 5(my example has just 2 for simplicity sake).
All the data is imported using the CF7 variables and ideally I wanted to clean this up a bit. What I had thought of as a solution was creating a second sheet that pulls in this data submitted in the first sheet into a more user friendly format, as I intended to use this as a work form for a designer to create the requested graphic once the data is received. With each request the name/department/email/date all stay the same, but I'd like to display the version and line 1 and 2 data on another line. Is it possible to reorganize data like this on the fly, so when a new form is submitted and adds data to sheet 1, sheet 2 would then update with the properly formatted info?
Is this even possible to do? I did some looking online, but didn't anything that really related to this type of data manipulation.
Solution:
Here's what ended up working for my example
=ArrayFormula(QUERY({
Sheet1!A2:D,Sheet1!E2:G,ROW(Sheet1!A2:A);
IFERROR(LEN(Sheet1!A2:D)/0),Sheet1!H2:J,ROW(Sheet1!A2:A);
IFERROR(LEN(Sheet1!A2:D)/0),Sheet1!K2:M,ROW(Sheet1!A2:A);
IFERROR(LEN(Sheet1!A2:D)/0),Sheet1!N2:P,ROW(Sheet1!A2:A);
IFERROR(LEN(Sheet1!A2:D)/0),Sheet1!Q2:S,ROW(Sheet1!A2:A)
},"select Col1,Col2,Col3,Col4,Col5,Col6,Col7 where Col5<>'' order by Col8",1))
Yes, it's possible.
One way is to use arrays and the QUERY function.
For simplicity, let say that
Columns A and B have the general information of the order
Columns C and D have the data for version 1
Columns E and F have the data for version 2
Columns G and H have the data for version 3
On the output sheet, add the headers.
Below of them add a formula like the following:
=ArrayFormula(QUERY({A2:B,C2:D,ROW(A2:A);IFERROR(LEN(A2:B)/0),E2:F,ROW(A2:A);IFERROR(LEN(A2:B)/0),G2:H,ROW(A2:A)},"select Col1,Col2,Col3,Col4 where Col3<>'' order by Col5"))
References start on row 2 to skip the headers to avoid to include them on the output sheet.
ROW(A2:A) is used to keep the order
IFERROR(LEN(A2:B)/0) is a "trick" used to "hide" the order (general information) data for the second and following rows for the same order. On the select parameter of the QUERY function, it's referrey as Col5 on the order by clause.
It's assumed that lookup-choice-1 will never be empty.
NOTES:
If more columns were added, the column numbers should be updated accordingly
Don't use the order by clause to sort the result by the general information columns because the "trick" to hide the "labels". If you need to apply a sort, do it' before applying the above formula, you could do this by sorting the source range through the Data > Sort range... feature, so the data is sorted before it's transformed by the above formula.
See also
Sort and filter your data, an official help article describing Data > Sort range...

custom vaadin-grid filter for Polymer 1.0

I’m using the vaadin-grid#^3.0.2 in my polymer 1.0 project.
But I’m looking to create an on/off toggle button that will filter a column based on if the text in two columns are not a match. So if a row in column 1 contains text=“1.1.1” and that same row in column 2 contains text = “2.1.1" then I would keep this row displayed, and hide all other rows. I want to do this in javscript. I’m very new to the vaadin-grid (had so much previous experience with iron-data-table). Anyone have a suggestion on how I can access the filter function?
image of 2 different columns of versions
I tried using the standard filter element but it's too limiting because it only allows me to do string based filtering on just one-specific column, but it's not built so I can do a comparison between strings in two different columns.
<vaadin-grid-filter path="version" value="[[_filterVersion]]">
<input value="{{_filterVersion::input}}">
</vaadin-grid-filter>
One simple way to do filtering that looks at the values of two columns is to not use vaadin-grid-filter, rather just have a input field outside the grid, then filter the array bound to the grid's items property as needed.
<vaadin-textfield on-value-changed="_filterMethod"></vaadin-textfield>
_filterMethod(evt) {
this.gridItems = this.allItems.filter(it => it.col1 !== it.col2);
}
Although I may not fully understand your question as I don't why you are using an input field instead of a button. This filter method approach should work equally well if you call it from a button instead.

Filter by multiple values

To explain what I want to do, I will show a much simpler version of my spreadsheet:
I want to be able to filter the Tags to filter column using multiple value of the column Filters available.
For instance, if I select the filters available e and d, I will get back only the lines 15,15 and 17.
My problem is that I don't know how to select the filters that I want and filter the table.
The perfect solution would be to have a list with checkboxes like the one shown in the following picture:
But instead of showing the exact values in this column, it should show the ones in the Filters available table, and after it would filter to show the lines that contains at least one of the options selected...
Do you think I made my question clear?
Try using one extra column with filter condition:
In this sample:
Range A2:A8 = filters available
Range B2:B8 = range where user selects, which filter to use, pasting ones.
Range D2:D9 = tags to filter
Range E2:E9 = extra column with condition
You need only one formula in cell E2:
=ArrayFormula(REGEXMATCH(D2:D9,JOIN("|",FILTER(A2:A8,B2:B8=1))))
ArrayFormula will make it expand down to row 9 automatically. Select your range instead of D2:D9.
REGEXMATCH checks if tags contains selected filters.
JOIN makes string like this: "a|c|e|g" which makes REGEXMATCH to check for any of selected filters: a OR c OR e OR g.
A very easy way of doing this it to use a Pivot Table.
Highlight the data you want to use, then select Pivot Table from the Data menu.
Then Add field to select the Rows and Columns you are after, and include the column you want to filter by in the Filter field
Then you can use the built in Pivot Table Filter to show what you are after.
Giant image showing how to setup and use a pivot table in google sheets
here is a link to the google help for how to create a pivot table:
Link to google help tutorial for how to use pivot tables

Resources