KQL for Non-Techies: Exploring Data Without Coding Fear
Simple KQL queries using relatable analogies, so you can start exploring data without fear
If you're a business analyst, manager, or anyone who works with data but shies away from coding, you might feel intimidated by tools that seem built for tech wizards. Enter Kusto Query Language (KQL), a powerful yet surprisingly approachable way to explore data in tools like Azure Data Explorer. Think of KQL as your friendly guide to digging through data—like sorting through a pile of laundry to find exactly what you need. In this beginner-friendly post, we’ll walk through simple KQL queries using relatable analogies, so you can start exploring data without fear.
What is KQL, Anyway?
KQL is a query language designed to help you ask questions about large datasets, like logs from websites, apps, or IoT devices. It’s used in platforms like Azure Data Explorer to find insights without needing to be a coding expert. Imagine KQL as a librarian who can quickly fetch specific books (data) from a massive library (database) based on your instructions.
You don’t need to know programming to use KQL. It’s like giving clear directions to that librarian—tell them what you want, and they’ll bring it to you. Let’s dive into some simple KQL queries using a dataset of online store orders to show how easy it can be.
Our Dataset: A Virtual Store
Picture a dataset as a giant basket of laundry—your online store’s order history. Each piece of laundry (a row in the dataset) represents an order with details like the customer’s name, order date, product, and price. Here’s what it might look like:
We’ll use KQL to explore this data with simple commands. Let’s get started!
Query 1: Looking at Your Data (Peeking into the Laundry Basket)
The first thing you might want to do is see what’s in your dataset. In KQL, this is like glancing into your laundry basket to see what’s there. The query is super simple:
Orders
This tells KQL to show you the entire dataset, like dumping the whole laundry basket on the floor. If you run this in Azure Data Explorer, you’ll see all the rows, like the table above. No filters, no fuss—just the raw data.
Query 2: Filtering Data (Sorting Laundry by Color)
Now, let’s say you only want to see orders for T-Shirts, like sorting out all the blue socks from your laundry. In KQL, you use the where
operator to filter data. Try this:
Orders
| where Product == "T-Shirt"
This query says, “Show me only the orders where the product is a T-Shirt.” The ==
means “equals,” so you’re telling KQL to pick out just those items. The result would be:
The |
(pipe) symbol is like passing your laundry to the next step in the process—here, it hands the data to the where
command to do the filtering. Easy, right?
Query 3: Counting Items (How Many T-Shirts Are There?)
What if you want to know how many T-Shirt orders you have? This is like counting how many blue socks you found. KQL’s count
operator makes this a breeze:
Orders
| where Product == "T-Shirt"
| count
This query filters for T-Shirts (like before) and then counts how many orders match. The result might look like:
You’ve just learned there are two T-Shirt orders. Think of count
as tallying up items in a category, like counting socks, shirts, or towels in your laundry.
Query 4: Summarizing Data (What’s the Total Price of T-Shirts?)
Now, let’s say you want to know the total price of all T-Shirt orders, like adding up the cost of all the blue socks you’re washing. KQL’s sum
function can help:
Orders
| where Product == "T-Shirt"
| summarize TotalPrice = sum(Price)
Here, summarize
is like grouping your laundry into a neat pile and calculating something about it—in this case, the total price. The result would be:
This tells you the total price of T-Shirt orders is 40 (20 + 20). You can think of summarize
as your way to ask, “What’s the big picture for this group of data?”
Query 5: Sorting Results (Organizing Laundry by Date)
Sometimes, you want your data in a specific order, like sorting your laundry by when you wore it. In KQL, the sort
operator (or order
) arranges your results. Let’s sort all orders by date:
Orders
| sort by OrderDate
This query organizes the dataset by OrderDate
, showing the oldest orders first. The result would look like the original table, since the dates are already in order, but if they weren’t, KQL would rearrange them for you. You can also sort in reverse by adding desc
:
Orders
| sort by OrderDate desc
Now, the most recent orders appear first, like putting the freshest laundry on top.
Why KQL is Perfect for Non-Techies
KQL is designed to be intuitive, like giving simple instructions to a helpful assistant. You don’t need to memorize complex coding rules—just a few key words like where
, count
, summarize
, and sort
. Each query is like building a sentence: start with your data (the laundry basket), add a verb (filter, count, summarize), and specify what you’re looking for.
Here are a few tips to keep exploring without fear:
Start Small: Begin with simple queries like the ones above. Play with a sample dataset in Azure Data Explorer’s free sandbox environment.
Use Analogies: Think of your data as something familiar, like laundry, a recipe book, or a shopping list. It makes the concepts less intimidating.
Experiment: KQL is forgiving. If a query doesn’t work, tweak it and try again. It’s like rearranging items in your basket until you find what you need.
Ask for Help: Azure Data Explorer has built-in query examples, and there are tons of free tutorials online to guide you.
Your Next Steps
Ready to try KQL? Head to Azure Data Explorer’s web interface, where you can experiment with sample datasets. Start by typing Orders
to see a dataset, then try filtering with where
or counting with count
. Think of each query as a question you’re asking your data—what do you want to know?
KQL isn’t just for coders; it’s for anyone who wants to uncover insights from data. So, grab your virtual laundry basket, start sorting, and discover how fun exploring data can be!
Read to get started right? Check out the Must Learn KQL series, which has proven to be the best for beginners.