Query data in a KQL queryset

In this article, you learn how to use a KQL queryset. The KQL Queryset is the item used to run queries, view, and customize query results on data from different data sources, such as Eventhouse, KQL database, and more.

The KQL Queryset uses the Kusto Query Language for creating queries, and also supports many SQL functions. For more information about the query language, see Kusto Query Language overview.

Prerequisites

Select a database

Queries run in the context of a database. You can change the associated database at any point, and retain the queries saved in the query editor. You can associate your KQL queryset with multiple data sources of different types, including a KQL database or a database from an Azure Data Explorer cluster.

Select the tab that corresponds with your desired database type.

  1. Open your KQL queryset.

  2. In the connection pane on the left-hand side of the query page, under Explorer, select V to expand the database connections menu.

    Screenshot of the database menu showing a list of connected databases.

  3. Under Connect source, select OneLake data hub.

  4. In the OneLake data hub window that appears, select a KQL database to connect to your KQL queryset, and then select Connect. Alternatively, close theOneLake data hub window and use the +Add data source menu to connect to a different data source.

A list of tables associated with this database appears below the database name in the connection pane.

Interact with databases using the connection pane

The connection pane allows you to browse and switch between the databases connected to the queryset. In the connection pane, under Database, select V to expand the database connections menu. Select the database you want to explore. The connection pane shows a breakdown of the following items that are included in the selected database:

  • Tables
  • Materialized View
  • Shortcuts
  • Functions

In the connection pane, you can explore what items are included in each section. To open the action menu, hover over the item and select the More menu [...]. The menu gives options to:

  • Refresh data
  • View data profile
  • Insert to create a script and paste it in to the query editor
  • Delete

Different actions are available for different types of items.

Write a query

Now that you're connected to your data source, you can run queries on this data. The KQL Queryset uses the Kusto Query Language (KQL) to query data from any of the databases you have access to. To learn more about KQL, see Kusto Query Language overview.

The following examples use data that is publicly available at https://kustosamples.blob.core.windows.net/samplefiles/StormEvents.csv.

  1. Write or copy a query in the top pane of the KQL Queryset.

  2. Select the Run button, or press Shift+Enter to run the query.

    The resulting query output is displayed in the results grid, which appears below the query pane. Notice the green check indicating that the query completed successfully, and the time used to compute the query results.

    Screenshot of the KQL Queryset showing the results of a query. Both the query and the results pane are highlighted.

Manage queryset tabs

Within a KQL queryset, you can create multiple tabs. Each tab can be associated with a different KQL database, and lets you save queries for later use or share with others to collaborate on data exploration. You can also change the KQL database associated with any tab, allowing you to run the same query on data in different states.

Screenshot of the options for editing tabs in the KQL Queryset.

  • Add a new tab: Select the plus + to the right of the existing tabs. Different tabs can be connected to different databases.
  • Rename a tab: Select the pencil icon next to the tab name.
  • Change tab positions: Change tab positions using drag and drop gestures.
  • Change the existing database connection: Under Explorer, select the existing database connection to open the data hub.

On the right side of the command bar, there is a menu with additional actions to manage the multiple tabs in your queryset.

Screenshot of the multiple tabs menu for managing multiple tabs in the KQL Queryset.

Copy query

You might want to copy and share the queries you create.

  1. At the top of the query window, select the Home tab.

  2. In the query pane, select Copy query.

    Screenshot of the Manage tab of the KQL Queryset showing the dropdown of the copy query or query results option.

    The following table outlines the many options for how to copy a query.

    Action Description
    Copy query Copy the query text.
    Link to clipboard Copy a deep link that can be used to run the query.
    Link and query to clipboard Copy a link that can be used to run the query and the text of the query.
    Link, query and results to clipboard Copy a link that can be used to run the query, the text of the query, and the results of the query.
    Copy results Copy the results of the query.
  3. Select the desired action from the above table.

  4. Paste this information to edit or share it, for example in Microsoft Word, Microsoft Teams or Outlook.

    Important

    The user who is receiving the query link must have viewing permissions to the underlying data to execute the query and view results.

Export query data as CSV

Instead of simply copy-pasting the query output, you can also export the query results.

This is a one-time method to export a CSV file containing the query results.

  1. At the top of the query window, select the Home tab.

    Screenshot of the Home tab of the KQL Queryset showing the highlighted option to export results to CSV.

  2. In the query pane, select Export to CSV.

  3. Save the CSV file locally.

Delete KQL queryset

To delete your KQL queryset:

  1. Select the workspace in which your KQL queryset is located.

  2. Hover over the KQL queryset you wish to delete. Select More [...], then select Delete.

    Screenshot of Microsoft Fabric workspace showing how to delete a KQL queryset.

Next step