Write LookML with Gemini assistance

Gemini in Looker provides generative AI-powered assistance to help you work with your data. In the Looker IDE, the Help me code panel uses Gemini in Looker to generate LookML code suggestions in response to written prompts. You can use Gemini to create dimensions, dimension groups, and measures in your LookML project.

Before you begin

To use Gemini in the Looker IDE, note the following requirements:

Use Gemini in the Looker IDE

To use Gemini for creating LookML in your Looker project, follow these steps:

  1. On your Looker instance, enable Development Mode.
  2. Open your project in the Looker IDE.
  3. Use the IDE file browser to open a LookML view file in which you want to insert LookML.
  4. Select the Help me code icon from the side panel selector.

    Looker IDE with Help me code icon highlighted.

  5. With the the Help me code panel open, click to place your cursor on a line in your LookML view file. Based on the type of LookML file and where your cursor is placed in the file, Gemini provides appropriate options to guide you, such as Create a dimension or Create a measure.

  6. Select one of the following options from the Help me code panel:

    • Create a dimension group
    • Create a dimension
    • Create a measure
    • Other code suggestion: You can use the other code suggestion option if you want to try out different LookML elements. Remember that Gemini is an early-stage technology, so validate and test all output before deploying it.
  7. In the Help me code panel text field, use conversational language to describe the dimension, dimension group, or measure that you want to create. See the Tips for using Gemini in the Looker IDE and Sample prompts sections on this page for guidance.

  8. Press Enter or click the Submit icon to send your request to Gemini. Gemini will respond with suggested code.

  9. With the suggested code, you can do the following:

    • Hold your pointer over the Insert button to preview the suggested LookML in your file. You can move your cursor to a different line in your file to preview it in a different location before inserting the LookML in the file.
    • Click the Edit button to manually change the suggested LookML.
    • Click the Insert button to insert the LookML into your file at the location of your cursor.
    • Provide feedback about the suggested code by selecting the thumbs up icon (This response was helpful) or thumbs down icon (This response was not what I expected).
    • Click the New code suggestion link to start over and enter a new prompt for Gemini.

    Gemini showing a preview of the code placement when the cursor is hovered over the Insert button.

  10. Click Save Changes in your LookML file.

  11. Verify the LookML by doing the following:

Tips for using Gemini in the Looker IDE

Here are some tips for using Gemini in the Looker IDE:

  • For best results, write your prompts in American English. See the Gemini for Google Cloud limitations documentation for more information.
  • The Help me code panel does not retain context from a previous prompt in the conversation and does not retain prompts across logins and refreshes.
  • When you use LookML that was suggested by Gemini, always validate your LookML with the LookML Validator, and test your new fields in an Explore.
  • Depending on your request, Gemini may suggest LookML that references fields in other view files. When you add suggested LookML to your file, save the file and run the LookML Validator. The LookML Validator will display errors if you need to add include statements to your model file.

Sample prompts

To give you some ideas, here are some example prompts and their results:

Create a dimension using longitude and latitude

Here is a prompt using the Create a dimension option that asks Gemini to create a new dimension based on the longitude and latitude fields that are defined in the view file:

show coordinates with longitude and latitude

Gemini returns this suggested code:

   dimension: coordinates {
      type: location
      sql_latitude: ${TABLE}.latitude ;;
      sql_longitude: ${TABLE}.longitude ;;
   }

You can verify this LookML in an Explore by selecting the new coordinates field, along with the longitude and latitude fields it's based on. Because Gemini created the dimension using type:location, the Explore results include a hyperlink to view the coordinates on a map:

Looker Explore showing the latitude and longitude fields, with the new coordinates field with values that match the latitude and longitude values.

Create a measure for today's total sales

Here is a prompt using the Create a measure option that asks Gemini to create a new measure for the sum of all of today's orders:

show the total sale price of today's orders

Gemini returns this suggested code:

   measure: todays_orders {
      type: sum
      sql: ${basic_order_items.sale_price} ;;
      filters: [basic_order_items.created_at_date: "today"]
  }