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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MokaSatya
Microsoft Employee
Microsoft Employee

Parameter to M Query

Hello Experts ,

 

I have a requirement to pass the parameter to M Query , below is the  M Query generated by KUSTO, i have created a Date parameter in the Power Query , my requirement is to pass theDate parameter to the below code , how can i include the Parameter in the below highlighted area , i tried to append using +, not supporting. 

 

 

let Source = Json.Document(Web.Contents("https://CLUSTER/rest/query?db=MYDATABASE0&csl=.show version",[Query=[#"csl"="let startTime = datetime(2020-06-20); XXXXTable1 | where EventInfo_Time >=startTime | where Environment == 'Prod' | where Hint == ""LeftNav"" and Value in (""True"",""False"") | extend scenario = iff(Value=='True','Treatment','Control') | summarize eventCount=count(),userCount=dcount(Puid) by bin(EventInfo_Time,1d),scenario",#"x-ms-app"="PowerQuery",#"properties"="{""Options"":{""servertimeout"":""00:12:00"",""query_language"":""csl""},""Parameters"":{},""ClientRequestId"":null,""Application"":null,""User"":null,""PrincipalIdentity"":null,""SecurityToken"":null,""AuthorizationScheme"":null,""RequestHostName"":null,""LocalClusterName"":null,""OriginClusterName"":null}"], Timeout=#duration(0,0,12,0)])),

TypeMap = #table(
{ "DataType", "Type" },
{
{ "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 }
}),
Exception = Source[Exceptions]?{0}?,
Result = if (Exception <> null) then
error Exception
else
let
DataTable = Source[Tables]{0},
Columns = Table.FromRecords(DataTable[Columns]),
ColumnsWithType = Table.Join(Columns, {"DataType"}, TypeMap , {"DataType"}),
TableRows = Table.FromRows(DataTable[Rows], Columns[ColumnName]),
LastColumn = Table.ColumnCount(ColumnsWithType) - 1,
TypedTable = Table.TransformColumnTypes(TableRows, Table.ToList(ColumnsWithType, (c) => { c{0}, c{LastColumn} }))
in
TypedTable
in
Result
in KustoQuery

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @MokaSatya 

 

You can use " & parameterName & ", this parameter needs to return text or you can use Text.From() function around it.

db=MYDATABASE0&csl=.show version",[Query=[#"csl"="let startTime = datetime(" & ParamiterName & ");

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

2 REPLIES 2
Mariusz
Community Champion
Community Champion

Hi @MokaSatya 

 

You can use " & parameterName & ", this parameter needs to return text or you can use Text.From() function around it.

db=MYDATABASE0&csl=.show version",[Query=[#"csl"="let startTime = datetime(" & ParamiterName & ");

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Super, Thanks for the quick solution. it is working 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.