Forum Discussion
Add default values to Parameters in Navigation Table
Hello Experts,
I am trying to add start and end dates parameters to a Navigation table with default values as today's date for a data connetor so that user can provide values while loading data. Can someone please provide pointers how to achieve this via M language. Following is what I managed to achieve so far. I get to see the startDate and endDate input fields where user can key in values. But couldn't manage to show default values in those input fields.
Also how do we pass a list of values to a parameter in Navigation table.
let
source = #table({"Name", "Data", "ItemKind", "ItemName", "IsLeaf"}, {
{ "UserSearch", (startDate as text, endDate as text) => GetUserSearchTable(startDate, endDate), "Table", "Table", true }
{ "Users", GetUsersTable(), "Table", "Table", true }
}),
navTable = Table.ToNavigationTable(source, {"Name"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
in
navTable;
GetUserSearchTable = (startDate as text, endDate as text) as table =>
let
body = "{ ""endDate"" : """&endDate&""" , ""startDate"" : """&startDate&"""}",
source = Web.Contents("https://rest.api/users", [ RelativePath = "search", Content = Text.ToBinary(body)]),
json = Json.Document(source),
#"Converted to Table" = Record.ToTable(json),
Value = #"Converted to Table"{0}[Value],
#"Converted to Table1" = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"userID"}, {"userID"}),
#"Renamed Columns" = Table.RenameColumns(#"Expanded Column1",{{"userID", "Id"}}),
#"Invoked Custom Function" = Table.AddColumn(#"Renamed Columns", "GetListTable", each GetListTable([Id])),
#"Expanded Users" = Table.ExpandTableColumn(#"Invoked Custom Function", "GetListTable", {"name", "type"}, {"name", "type"})
in
#"Expanded Users";
4 Replies
- parry2kSuper User
ppraveenk I don't think there is a way to set the default value of parameters to today's date.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
- ppraveenkFrequent Visitor
I am looking for some inputs to set default vaulue in a text parameter field. Any pointers would be greatly helpful.