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.
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";
@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.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k thanks for your response. I've seen this possible in one of the connectors. PFB
If not date, can we show some default text? How do we set anything as default value and pas the list to a prameter. I've gone through lot of forums but did not find any hints on this.
I am looking for some inputs to set default vaulue in a text parameter field. Any pointers would be greatly helpful.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
100 | |
78 | |
69 | |
63 |
User | Count |
---|---|
141 | |
106 | |
101 | |
85 | |
72 |