How to Query Function Google Spreadsheet - Data filtering based on multiple criteria (multiple columns to check at once) - filtering

I have a Google Spreadsheet that contains five (5) sheets, and we are starting to use them as a basic CRM to manage tasks, projects, deadlines and customers in a very basic fashion.
We assign tasks to each other in the first sheet "TaskRecords", and then we will populate the other sheets with the information there.
This the google spreadsheet (with mock data):
https://docs.google.com/spreadsheet/ccc?key=0AkB1z6YLt9N_dDU0VGgyZjN5cGt2UmtRb05FbWRRZ1E#gid=6
What I would like to achieve is to filter by means of a Query function or so, to use the spreadsheet as a database and filter the following: Taks by Team Member, by Customer, by Deadline, by Project, etc, and displaying the on other sheets.
I tried with Query formula: =QUERY(TaksRecords!A2:I17; "select A, B, C, D, E, F, H, I where G="AL""; 1). Where I would like to filter everything that Team Member "AL" has been assigned to do, but I'm missing something.
I also tried to pull data out to other sheets using Arrayformula, but it only fetchs the cells I tell it to, and does no filtering based on multiple criteria at the same time.
Furthermore, there will be new rows of data added every day.
Maybe there is some script already written that solves this, I've been testing for several days with different options but couldn't get them to work.
Any hints?
Thanks.

Use this query
=QUERY(JOURNAL!A1:E100, "select A, B, C, D, E where col1='Fruit' and Col2='Sweet'", 1)

It's just a matter of quotes. Try this, with single quotes around the name 'AL':
=QUERY(TaksRecords!A2:I17; "select A, B, C, D, E, F, H, I where G='AL'"; 1)

I'm no expert in this area, but I would use FILTER instead of QUERY. I use Query for a pre-defined formula to find certain records, and Filter to take a large quantity of records and narrow it down by certain defined criteria. Query is nice and clean, but it appears FILTER will suit your needs better.

How about doing a query of two conditions like:
WHERE Col1='Fruit' AND Col2='Sweet'

Related

Comparing multiple columns for match

Can someone please assist me with the following.
I have a data base of member names. names in column C (Main). I then want to compare this column to another database column c, d, e, f, g, h, i, j, k, l on another sheet (booked via google form) for a match, resulting in a tickbox to be marked if the name on the main sheet is listed on the (booked via google form) sheet.
Currently im using this formula to compare and tick the box, but its limited to only comparing it to one column and not multiple columns.
=IF(ISERROR(MATCH(C3,'Booked via google form'!C:C,0)),False,TRUE)
is there a better way to do this or can this be adjusted to look for a match in multiple columns?
Ok so did some searching and found the following formula that works.
=IF(COUNTIF('Booked via google form'!C:L, ""&C3&"")=0, FALSE, TRUE)
This allows me to search through all the names on the booked via form sheet.
any additional input is still welcome.

How to get all missing days between two dates

I will try to explain the problem on an abstract level first:
I have X amount of data as input, which is always going to have a field DATE. Before, the dates that came as input (after some process) where put in a table as output. Now, I am asked to put both the input dates and any date between the minimun date received and one year from that moment. If there was originally no input for some day between this two dates, all fields must come with 0, or equivalent.
Example. I have two inputs. One with '18/03/2017' and other with '18/03/2018'. I now need to create output data for all the missing dates between '18/03/2017' and '18/04/2017'. So, output '19/03/2017' with every field to 0, and the same for the 20th and 21st and so on.
I know to do this programmatically, but on powercenter I do not. I've been told to do the following (which I have done, but I would like to know of a better method):
Get the minimun date, day0. Then, with an aggregator, create 365 fields, each has that "day0"+1, day0+2, and so on, to create an artificial year.
After that we do several transformations like sorting the dates, union between them, to get the data ready for a joiner. The idea of the joiner is to do an Full Outer Join between the original data, and the data that is going to have all fields to 0 and that we got from the previous aggregator.
Then a router picks with one of its groups the data that had actual dates (and fields without nulls) and other group where all fields are null, and then said fields are given a 0 to finally be written to a table.
I am wondering how can this be achieved by, for starters, removing the need to add 365 days to a date. If I were to do this same process for 10 years intead of one, the task gets ridicolous really quick.
I was wondering about an XOR type of operation, or some other function that would cut the number of steps that need to be done for what I (maybe wrongly) feel is a simple task. Currently I now need 5 steps just to know which dates are missing between two dates, a minimun and one year from that point.
I have tried to be as clear as posible but if I failed at any point please let me know!
Im not sure what the aggregator is supposed to do?
The same with the 'full outer' join? A normal join on a constant port is fine :) c
Can you calculate the needed number of 'dublicates' before the 'joiner'? In that case a lookup configured to return 'all rows' and a less-than-or-equal predicate can help make the mapping much more readable.
In any case You will need a helper table (or file) with a sequence of numbers between 1 and the number of potential dublicates (or more)
I use our time-dimension in the warehouse, which have one row per day from 1753-01-01 and 200000 next days, and a primary integer column with values from 1 and up ...
You've identified you know how to do this programmatically and to be fair this problem is more suited to that sort of solution... but that doesn't exclude powercenter by any means, just feed the 2 dates into a java transformation, apply some code to produce all dates between them and for a record to be output for each. Java transformation is ideal for record generation
You've identified you know how to do this programmatically and to be fair this problem is more suited to that sort of solution... but that doesn't exclude powercenter by any means, just feed the 2 dates into a java transformation, apply some code to produce all dates between them and for a record to be output for each. Java transformation is ideal for record generation
Ok... so you could override your source qualifier to achieve this in the selection query itself (am giving Oracle based example as its what I'm used to and I'm assuming your data in is from a table). I looked up the connect syntax here
SQL to generate a list of numbers from 1 to 100
SELECT (MIN(tablea.DATEFIELD) + levquery.n - 1) AS Port1 FROM tablea, (SELECT LEVEL n FROM DUAL CONNECT BY LEVEL <= 365) as levquery
(Check if the query works for you - haven't access to pc to test it at the minute)

Grouping By with missing data

Image of Data and desired result:
I'm trying to aggregate volunteer hours from a Google spreadsheet a non-profit I volunteer for. We collect volunteer e-mail information and the time that each volunteer has contributed. Each volunteer only puts in their e-mail the first time. I've found examples online on how to send e-mails, but I'm having trouble aggregating the data. I think the trouble might be that not every row has an e-mail address associated with it.
I've been able to get the sum of hours worked by volunteer using QUERY(data, "select A, sum(C) Group By A", ) but can't figure out how to get the e-mail associated with each individual.
Thanks for the advice! The VLOOKUP and ArrayFormula functions were new to me. Here's how I solved it:
QUERY(data, "select A, B where B <>'' ", -1)
This allowed me to get the Key-Value pair (Name, Email) for each volunteer (solving the problem of people who volunteered multiple times, but only left their e-mail once). From there, I was able to generate the 'Name:Hours Worked' table off to the right with:
QUERY(data, "select A, sum(C) Group By A", ).
Then, I used VLOOKUP to query my Name-Email table to get the desired result of:
Name-Email-aggregatedHours
Thanks!
You can't achieve this with query. But you could apply vlookup to sorted table:
=ArrayFormula(VLOOKUP(UNIQUE(FILTER(A2:A,A2:A<>"")),SORT(A2:B,2,0),2,0))
and get email list for unique names.
First, clean up your data. You shoud be certain that at least one column has no typos an that this column appropiate identify which data corresponds to each volunteer. This is called key value. This also could be done by, but not limited to, filling up the missing values for each row. If this will be hard, then
Create a volunteer list without missing data.
Calculate the time contributed by each volunteer. If you was able to fill up the missing values, then you could use QUERY, I this case the QUERY formula should have to group by name and email, if not, then use SUMIF

Tableau context parameter

I have 3 dimensions in the following hierarchy:
BigC
L SmallC
L Brand
(Having 200 combinations)
I am also creating a calculation using a parameter and multiple case statements.
For eg: CASE WHEN parameter=Brand1 THEN Brand1_field - Impact% END
Now I want my parameter to have only the relevant brand values populated for Big C and Small C rather than all the values. Is it possible?
If this is not possible then can I create a calculated field with a column selection?
If i have understood your question properly, I was able to achieve this using Context filter and Filter by Relevant Values.
Drop both Big Company and Small Company dimensions into Filter Card.
Apply Context Filter for Big Company and "Use only relevant values" for Small Company filter.
So as when you select values for Big Company only the related values of small company will be displayed and so the brands.
Find the workbook here : https://www.dropbox.com/s/txam3wfhz8qirqg/StackOverflowSolution.twbx?dl=0

How to return a cell value if the date in a range of cells is today in google sheets

I currently have a Google Sheet, with numerous sheets in it, to track contract deadlines for different clients. One of these sheets shows me all of the deadlines in Columns E:M for every contract. Each row is a separate contract.
I'm trying to create a separate sheet that will show me the client's name, found in column A, if a date in columns E:M is Today. That way I can look at one page and see all the clients that have a deadline today. Here is what I tried with no success:
=if('U/C(Dont Edit)'E2:M2=TODAY(),'U/C(Dont Edit)'A2,"")
"U/C(Dont Edit)" is the sheet that shows all of the contracts.
I believe the problem lies when I try to apply "=Today()" to a range(E:M). It seems to work fine if I just use E2=Today(). It looks like I could accomplish my goal using If statements within If statements, but that gets very messy very quickly and I'm hoping there is a better way.
Thanks in advance for your help.
You can do it with the COUNTIF() function per row:
=IF(COUNTIF(E2:M2,TODAY())>0,A2,"")
But I think a better solution is to use the FILTER() function. It will give you a list of names:
=FILTER(A2:A,(E2:E=TODAY())+(F2:F=TODAY())+(G2:G=TODAY())+(H2:H=TODAY())+
(I2:I=TODAY())+(J2:J=TODAY())+(K2:K=TODAY())+(L2:L=TODAY())+(M2:M=TODAY()))
I suggest #dePatinkin's solution (for and additional column, say N, containing the COUNTIF formula from Row2 downwards) in combination with a query (in another sheet):
=query('U/C(Dont Edit)'!A:N,"select * where N is not NULL")
This assumes your existing sheet has the columns labelled.
You might combine the above with Conditional formatting to indicate which column has the date in it (today) that triggered the row selection.