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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MokaSatya
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors