O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Hannah Rampton: Getting started with Query in Google Sheets

642 visualizações

Publicada em

The Query function in Google Sheets is a powerhouse! It combines the capabilities of arithmetic functions with filtering abilities and you can use dynamic settings using nested vlookups. Hannah is going to simplify the query function, show you how to get started, along with some demonstrations on the power these unlocks for you.

Publicada em: Marketing
  • Seja o primeiro a comentar

Hannah Rampton: Getting started with Query in Google Sheets

  1. 1. HanR www.hannahrampton.co.uk 59of QUERYGetting started in Google Sheets 1
  2. 2. HanR www.hannahrampton.co.uk 59of2 ABOUT ME Technical SEO Consultant with over 10 years experience, having worked for agencies such as StrategiQ and SEOgadget (now Builtvisible). Awarded the Digital Marketing Award in 2018 at the DevelopHER awards for my innovations and in- house tools and the Inspiration Award in 2019. HAN Freelance Consultant
  3. 3. WITH A SIMPLE QUERY UNLOCK GREAT POWER
  4. 4. HanR www.hannahrampton.co.uk 59of4 SEARCH CONSOLE QUICK INSIGHTS This tool works entirely on Query functions and is effectively advanced search features to help you explore your data. This tool uses relatively simple queries unlike the Cannibalisation Explore. DETAILS DOWNLOAD bit.ly/GSCsheet
  5. 5. HanR www.hannahrampton.co.uk 59of5
  6. 6. HanR www.hannahrampton.co.uk 59of6
  7. 7. HanR www.hannahrampton.co.uk 59of7 CANNIBALISATION EXPLORER Using Google Data Studio, this tool helps you discover potential cannibalisation. This uses blended GSC data via the API to count landing pages per query and compare metrics. DETAILS DOWNLOAD bit.ly/KW-C
  8. 8. HanR www.hannahrampton.co.uk 59of8 CANNIBALISATION EXPLORER This sheet compliments the Data Studio report and uses the exported data. It returns the keyword with the count of URLs, the top 10 URLs transposed with impression distribution shown. DETAILS DOWNLOAD bit.ly/KW-C
  9. 9. HanR www.hannahrampton.co.uk 59of9
  10. 10. GETTING STARTED WITH THE QUERY FUNCTION
  11. 11. HanR www.hannahrampton.co.uk 59of11 INTRODUCING QUERY The query function runs a Google Visualization API Query Language query across data.
  12. 12. HanR www.hannahrampton.co.uk 59of12 BEN COLLINS It allows you to use powerful database code (a pseudo- SQL, Structured Query Language, the code used to communicate with databases) to manipulate your data in Google Sheets and it’s SUPER powerful. https://www.benlcollins.com/
  13. 13. HanR www.hannahrampton.co.uk 59of13 BEN COLLINS It allows you to use powerful database code (a pseudo- SQL, Structured Query Language, the code used to communicate with databases) to manipulate your data in Google Sheets and it’s SUPER powerful. It’s arguably the most powerful function in Google Sheets. https://www.benlcollins.com/
  14. 14. HanR www.hannahrampton.co.uk 59of14 INTRODUCING QUERY It combines filtering with arithmetic functions and aggregation such as AVG, SUM, MAX, COUNT, allowing you to both cleanse and calculate in a single query.
  15. 15. HanR www.hannahrampton.co.uk 59of15 SYNTAX =QUERY(table1,“pseudo-SQL here“,[optional headers])
  16. 16. HanR www.hannahrampton.co.uk 59of16 SYNTAX =QUERY(table1,“pseudo-SQL here“,[optional headers]) Data - Table or Range Optional headers (# of header rows) Query
  17. 17. HanR www.hannahrampton.co.uk 59of17 EXAMPLE STATEMENTS SELECT * WHERE A CONTAINS ‘SALE’ SELECT A,B,C WHERE B > 10 SELECT A,B,C,D WHERE A MATCHES ‘motorcycle|motorbike'
  18. 18. HanR www.hannahrampton.co.uk 59of18 SYNTAX =QUERY(table1,“SELECT * WHERE A CONTAINS ‘SALE’”,1)
  19. 19. HanR www.hannahrampton.co.uk 59of19 CLAUSES SELECT WHERE GROUP BY PIVOT ORDER BY LIMIT OFFSET LABEL FORMAT OPTIONS
  20. 20. HanR www.hannahrampton.co.uk 59of20 CLAUSES SELECT WHERE GROUP BY PIVOT ORDER BY LIMIT OFFSET LABEL FORMAT OPTIONS =QUERY(table1,“SELECT * WHERE A CONTAINS ‘SALE’”)
  21. 21. HanR www.hannahrampton.co.uk 59of21 CLAUSES SELECT WHERE GROUP BY PIVOT ORDER BY LIMIT OFFSET LABEL FORMAT OPTIONS =QUERY(table1,“SELECT * WHERE NOT A CONTAINS ‘SALE’”)
  22. 22. HanR www.hannahrampton.co.uk 59of22 CLAUSES SELECT WHERE GROUP BY PIVOT ORDER BY LIMIT OFFSET LABEL FORMAT OPTIONS =QUERY(table1,“SELECT * WHERE A CONTAINS ‘SALE’ ORDER BY C desc LIMIT 100”)
  23. 23. HanR www.hannahrampton.co.uk 59of23 CLAUSES SELECT WHERE GROUP BY PIVOT ORDER BY LIMIT OFFSET LABEL FORMAT OPTIONS =QUERY(table1,“SELECT * WHERE A CONTAINS ‘SALE’ ORDER BY C desc LIMIT 100 LABEL C ‘Top 100 Clicks Desc’”)
  24. 24. WHERE DO WE START? EXACTLY WHERE I DID
  25. 25. HanR www.hannahrampton.co.uk 59of25 MY FIRST QUERY
  26. 26. LET’S FLY THROUGH WITH THESE IN ACTION
  27. 27. HanR www.hannahrampton.co.uk 59of27 SELECT ALL Select *
  28. 28. HanR www.hannahrampton.co.uk 59of28 ONLY MOBILE Select * where B contains ‘mobile’
  29. 29. HanR www.hannahrampton.co.uk 59of29 CLICKS > 10 Select * where C > 10
  30. 30. HanR www.hannahrampton.co.uk 59of30 SUM AND GROUP Select A, B Sum C, D Group by A, B Label A, B, C, D
  31. 31. HanR www.hannahrampton.co.uk 59of31 SUM AND GROUP Select A, B Sum C, D Group by A, B Label A, B, C, D
  32. 32. HanR www.hannahrampton.co.uk 59of32 PIVOT AND GROUP Easy way to remember Group = Rows Pivot = Columns
  33. 33. PLUS CHECK OUT THIS TOOLBOX
  34. 34. HanR www.hannahrampton.co.uk 59of34 LOGICAL OPERATORS AND OR NOT =QUERY(table1,“SELECT * WHERE A CONTAINS ‘SALE’ AND B < 100”) https://developers.google.com/chart/interactive/docs/querylanguage#where
  35. 35. HanR www.hannahrampton.co.uk 59of35 LOGICAL OPERATORS AND OR NOT =QUERY(table1,“SELECT * WHERE A CONTAINS ‘SALE’ OR B < 100”) https://developers.google.com/chart/interactive/docs/querylanguage#where
  36. 36. HanR www.hannahrampton.co.uk 59of36 STRING COMPARISON Contains Starts with Ends with Matches Like =QUERY(table1,“SELECT * WHERE A CONTAINS ‘SALE’”) https://developers.google.com/chart/interactive/docs/querylanguage#where
  37. 37. HanR www.hannahrampton.co.uk 59of37 STRING COMPARISON Contains Starts with Ends with Matches Like =QUERY(table1,“SELECT * WHERE A MATCHES ‘motorcycle|motorbike'”) https://developers.google.com/chart/interactive/docs/querylanguage#where
  38. 38. HanR www.hannahrampton.co.uk 59of38 STRING COMPARISON Contains Starts with Ends with Matches Like =QUERY(table1,“SELECT * WHERE A MATCHES '.*b("&$B$4&")b.*'”) https://developers.google.com/chart/interactive/docs/querylanguage#where
  39. 39. HanR www.hannahrampton.co.uk 59of39 COMPARISON OPERATORS > < = <= >= != or <> (Not equal to) =QUERY(table1,“SELECT * WHERE B < 100”) https://developers.google.com/chart/interactive/docs/querylanguage#where
  40. 40. HanR www.hannahrampton.co.uk 59of40 COMPARISON OPERATORS =QUERY(table1,“SELECT * WHERE B >= 100”) https://developers.google.com/chart/interactive/docs/querylanguage#where > < = <= >= != or <> (Not equal to)
  41. 41. HanR www.hannahrampton.co.uk 59of41 COMPARISON OPERATORS =QUERY(table1,“SELECT * WHERE B IS NOT NULL”) https://developers.google.com/chart/interactive/docs/querylanguage#where Is Null Is Not Null
  42. 42. HanR www.hannahrampton.co.uk 59of42 ARITHMETIC + - * / https://developers.google.com/chart/interactive/docs/querylanguage#arithmetic-operators =QUERY(table1,“SELECT A,B,(C/D),E-D,F+G”)
  43. 43. HanR www.hannahrampton.co.uk 59of43 AGGREGATION avg() min() max() sum() count() https://developers.google.com/chart/interactive/docs/querylanguage#aggregation-functions =QUERY(table1,"SELECT SUM(B), SUM(D), AVG(H) LABEL SUM(B) 'All Clicks’, SUM(D) 'All Impressions’, AVG(H) 'Avg Position'")
  44. 44. HanR www.hannahrampton.co.uk 59of44 SCALAR lower() upper() dateDiff() toDate() now() https://developers.google.com/chart/interactive/docs/querylanguage#scalar-functions =QUERY(table1,“SELECT A,B WHERE lower(A) contains ‘sale’”)
  45. 45. HanR www.hannahrampton.co.uk 59of45 OTHER SHEET FUNCTIONS unique iferror if vlookup transpose Etc… =iferror(QUERY(table1,“SELECT A,B WHERE lower(A) contains ‘sale’”),”error”)
  46. 46. WITH THE BASICS COVERED LET’S GO BACK TO THE TOOLS
  47. 47. HanR www.hannahrampton.co.uk 59of47 Search Console Quick Insights Select where lower(A) is not null AND lower(A) matches B4 Order by vlookup value
  48. 48. HanR www.hannahrampton.co.uk 59of48 Cannibalisation Explorer Query selecting all, with some exclusions set via settings (not A contains) Wrapped in an IF and IFERROR
  49. 49. HanR www.hannahrampton.co.uk 59of49 Cannibalisation Explorer A progress bar guides the user through the information we need. This is output to the settings page and used by the query.
  50. 50. HanR www.hannahrampton.co.uk 59of50 Cannibalisation Explorer B >= Settings!A:B Not A contains Settings!D1:D5, F1 AND A contains Settings!L1 Order by B desc Limit by Settings!J:K
  51. 51. HanR www.hannahrampton.co.uk 59of52
  52. 52. HanR www.hannahrampton.co.uk 59of53
  53. 53. HanR www.hannahrampton.co.uk 59of54 Select A where A = Select A where A contains '"&A17&“’
  54. 54. HanR www.hannahrampton.co.uk 59of55 Select A where A = Select A where A contains '"&A17&“’ =if(isblank(A20),"(None matching)",concatenate("(found "&counta(A19:A)+1)&")")
  55. 55. HanR www.hannahrampton.co.uk 59of DOWNLOAD bit.ly/QuerySheets
  56. 56. HanR www.hannahrampton.co.uk 59of Thanks for your time! @hannahrampton contact@hannahrampton.co.uk www.hannahrampton.co.uk 58 AVAILABLE FOR FREELANCE SUPPORT
  57. 57. HanR www.hannahrampton.co.uk 59of59 RESOURCES 1. https://developers.google.com/chart/interactive/docs/querylanguage 2. https://www.benlcollins.com/spreadsheets/google-sheets-query-sql/ 3. https://infoinspired.com/google-docs/spreadsheet/learn-query- function-with-examples-in-google-sheets/ 4. https://www.seerinteractive.com/blog/how-to-query-data-in-google- sheets/

×