Query data in a KQL queryset
Important
Microsoft Fabric is in preview.
In this article, you learn how to create and use a new KQL queryset.
The KQL Queryset is the item used to run queries, view, and customize query results on data from a KQL database. Each tab in the KQL queryset can be associated with a different KQL database, and lets your 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.
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
- A workspace with a Microsoft Fabric-enabled capacity
- A KQL database with data
Create a KQL queryset
The KQL Queryset exists within the context of a workspace. A new KQL queryset is always associated with the workspace you're using when you create it.
Browse to the desired workspace.
Select +New > KQL Queryset
Enter a unique name. You can use alphanumeric characters, underscores, periods, and hyphens. Special characters aren't supported.
Note
You can create multiple KQL Querysets in a single workspace.
Select Create
Open an existing queryset
To access an existing queryset, browse to your workspace.
Select the desired KQL Queryset from the list of items.
Optionally, you can reduce the number of items displayed by filtering on the item type. Select Filter>KQL Queryset
Select the KQL queryset from the list of items that appear in the workspace.
Connect to 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.
- To connect your KQL queryset to a database, select Select database, and then select a database from the data hub that appears.
A list of tables associated with this database will appear below the database name.
Manage tabs
- Rename a tab: Select the pencil icon next to the tab name.
- Add a new tab: Select the plus + to the right of the existing tabs. Different tabs can be connected to different databases.
- Change the existing database connection: Under Database, select the existing database connection to open the data hub.
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.
Write or copy a query in the top pane of the KQL Queryset.
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 has finished successfully, and time used to compute the query results.
Copy query
You may want to copy or share the queries you create.
At the top of the query window, select the Manage tab.
Select Copy
You can either select Query to copy the text of the most recent query, or select Results to copy the output table.
You can now paste this information into any editor, such as Microsoft Word.
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.
At the top of the query window, select the Manage tab.
Select Export results to CSV.
Save the CSV file locally.
Delete KQL queryset
- Select the workspace to which your KQL queryset is associated.
- Hover over the KQL queryset you wish to delete. Select More [...], then select Delete.
Next step
Feedback
Submit and view feedback for