Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
How can i pass managed parameters througth a query.
I have created 2 managed parameters i want to filter by these variables
I have a record date table
how do i add these parameters in query and filter by RecordDate. i want all
the records between start date and up to an including end date using the parameter values i have defined
I have the following so far
let
// Define a function that takes Id and EventName as parameters
DynamicQuery = (Id as number, EventName as text) =>
let
// Construct the SQL query string dynamically using the function parameters and include filtering for RecordDate
QueryString = "SELECT TOP (10000) [RecordTime],[RecordDate], [Value], [VariableName] FROM [dbs].[myv] WHERE Id=" & Text.From(Id) & " AND EventName='" & EventName & "' ORDER BY RecordTime DESC",
// Connect to the database with the dynamic query string
Source = Sql.Database("myserver", "nydb", [CommandTimeout=#duration(0, 0, 1, 0), Query=QueryString]),
// Group rows by RecordTime
#"Grouped Rows" = Table.Group(Source, {"RecordTime"}, {{"AllData", each _, type table [RecordTime=datetime, RecordDate=date, Value=nullable text, VariableName=nullable text]}}),
// Expand AllData to include RecordDate along with Value and VariableName
#"Expanded AllData" = Table.ExpandTableColumn(#"Grouped Rows", "AllData", {"RecordDate", "Value", "VariableName"}, {"RecordDate", "Value", "VariableName"}),
// Change the type of Value to number
#"Changed Type" = Table.TransformColumnTypes(#"Expanded AllData",{{"Value", type number}}),
// Pivot the table based on VariableName
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[VariableName]), "VariableName", "Value", List.First)
in
#"Pivoted Column",
// Invoke the function with sample parameters
Result = DynamicQuery(71, "myevent")
in
Result
Solved! Go to Solution.
You can check this video,but be careful - you've created DATE parameter when your column is DATETIME!
You can check this video,but be careful - you've created DATE parameter when your column is DATETIME!