Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
VaibhavBhosle
New Member

KQL embedded in Power Query to query Defender Log through Advanced Hunting

let
AdvancedHuntingQuery = "
DeviceTvmSoftwareVulnerabilitiesKB
| where VulnerabilitySeverityLevel == "High"
",
HuntingUrl = "https://api.securitycenter.microsoft.cxxxxxxxxxxxxxxxx",
Response = Json.Document(Web.Contents(HuntingUrl, [Query=[key=AdvancedHuntingQuery]])),
TypeMap = #table(
{ "Type", "PowerBiType" },
{
{ "Double", Double.Type },
{ "Int64", Int64.Type },
{ "Int32", Int32.Type },
{ "Int16", Int16.Type },
{ "UInt64", Number.Type },
{ "UInt32", Number.Type },
{ "UInt16", Number.Type },
{ "Byte", Byte.Type },
{ "Single", Single.Type },
{ "Decimal", Decimal.Type },
{ "TimeSpan", Duration.Type },
{ "DateTime", DateTimeZone.Type },
{ "String", Text.Type },
{ "Boolean", Logical.Type },
{ "SByte", Logical.Type },
{ "Guid", Text.Type }
}),
Schema = Table.FromRecords(Response[Schema]),
Results = Response[Results],
Rows = Table.FromRecords(Results, Schema[Name])
in
Rows

1 ACCEPTED SOLUTION
Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @VaibhavBhosle,

 

To be clear, your question is how to use KQL queries in your Power Query, correct?

 

If that is the case I would suggest to have a look at a couple of Microsoft examples.

 

I found the below is example in the Azure Data Explorer connector documentation. It demonstrates how you could use a function for your KQL queries and use those in your Power Query M.

 

The example is from a different type of data source, but in concept you should be able to use the same for your setup.

 

https://learn.microsoft.com/en-us/power-query/connectors/azure-data-explorer#provide-parameters-to-a...

 



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel

View solution in original post

2 REPLIES 2
VaibhavBhosle
New Member

Thanks @Expiscornovus  much appreciated.

 

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @VaibhavBhosle,

 

To be clear, your question is how to use KQL queries in your Power Query, correct?

 

If that is the case I would suggest to have a look at a couple of Microsoft examples.

 

I found the below is example in the Azure Data Explorer connector documentation. It demonstrates how you could use a function for your KQL queries and use those in your Power Query M.

 

The example is from a different type of data source, but in concept you should be able to use the same for your setup.

 

https://learn.microsoft.com/en-us/power-query/connectors/azure-data-explorer#provide-parameters-to-a...

 



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.