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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rjs2
Resolver I
Resolver I

How to populate current value in a parameter using a query (only 1 in the list)

I am close to solving a problem.  I have greated a query that generates todays date and subracts 45 days from today. Then I coverted the query to a list and have it set for a parameter.  The problem I am having is that I can not set the current (no default option on parameter) to the value in the list.  The list only contains on option, which is the date 45 days ago.

 

How can I populate the parameter?image.png

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @rjs2 ,

 

It is not supported to enter dynamic value in "Current Value" field of parameter. One workaround is to create a list with "Today" like so:

let
    Source = List.Dates(Date.From(DateTime.LocalNow()),45,#duration(-1, 0, 0, 0)),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each if [Column1] = Date.From(DateTime.LocalNow()) then "Today" else [Column1]),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type text}})
in
    #"Changed Type"

today.JPG

 

parameter.JPG

 

Refer to the modified parameter:

    #"Filtered Rows" = Table.SelectRows(#"Converted to Table", each ( let ModifiedParameter = if Parameter1 = "Today" then Date.From(DateTime.LocalNow()) else Date.From(Parameter1) in [Column1] = ModifiedParameter))

filter.JPG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
LeoGorkes
New Member

@PhilipTreacy 
Did you find solutions about this topic?
i was unable to implement the above solution.

best regards

Icey
Community Support
Community Support

Hi @rjs2 ,

 

It is not supported to enter dynamic value in "Current Value" field of parameter. One workaround is to create a list with "Today" like so:

let
    Source = List.Dates(Date.From(DateTime.LocalNow()),45,#duration(-1, 0, 0, 0)),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each if [Column1] = Date.From(DateTime.LocalNow()) then "Today" else [Column1]),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type text}})
in
    #"Changed Type"

today.JPG

 

parameter.JPG

 

Refer to the modified parameter:

    #"Filtered Rows" = Table.SelectRows(#"Converted to Table", each ( let ModifiedParameter = if Parameter1 = "Today" then Date.From(DateTime.LocalNow()) else Date.From(Parameter1) in [Column1] = ModifiedParameter))

filter.JPG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PhilipTreacy
Super User
Super User

Hi @rjs2 

Well the way it's supposed to work is that in the Manage Parameters settings, you set it to use your query as the Suggested Value(s)

param1.png

 

But it will not work as expected for me.

 

But i you just want to use the result of your query in another query, just use the first query name to get that result, e.g.

 

Source = Query1

 

That said, why do you need a separate query to get today's date - 45 days?  You can do this directly in any query like so

let 
    Source = "...",
    Today_Minus_45 = Date.From(Date.AddDays(DateTime.LocalNow(), -45)),
    ........
in 
    LastStepName

 

Today_Minus_45 can be used anywhere in that query once it's created.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
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.