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
richard-powerbi
Post Patron
Post Patron

Parameter from dynamic value?

For incremental refresh I want to make a parameter called RangeEnd that takes yesterday's date. I thought I could use a list query Date.AddDays(DateTime.LocalNow(), -1) to make this parameter dynamic. But I can't get it to work. Here it says dynamic parameters are not possible. Is this still true? Does anyone know a way around this?

1 ACCEPTED SOLUTION
Smauro
Solution Sage
Solution Sage

Hi @richard-powerbi 

Based on your link:

Date.AddDays(DateTime.LocalNow(), -1) meta [IsParameterQuery=true, Type="DateTime", IsParameterQueryRequired=true]


And test:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Lcy5EYBAEMTAXNbGQMDxxLJ1+acBNcJpT+qutebSRdziHo844hmveMfH6o+tMcceB3jABT5wwneZLw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}),
    Test = Table.AddColumn(#"Changed Type", "Test", each DateTime.Date(Date.AddMonths(RangeEnd, -[Column1])), type date),
    #"Filtered Rows" = Table.SelectRows(Test, each [Test] > DateTime.Date(RangeStart) and [Test] <= DateTime.Date(RangeEnd))
in
    #"Filtered Rows"


image.png




Feel free to connect with me:
LinkedIn

View solution in original post

2 REPLIES 2
Smauro
Solution Sage
Solution Sage

Hi @richard-powerbi 

Based on your link:

Date.AddDays(DateTime.LocalNow(), -1) meta [IsParameterQuery=true, Type="DateTime", IsParameterQueryRequired=true]


And test:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Lcy5EYBAEMTAXNbGQMDxxLJ1+acBNcJpT+qutebSRdziHo844hmveMfH6o+tMcceB3jABT5wwneZLw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}),
    Test = Table.AddColumn(#"Changed Type", "Test", each DateTime.Date(Date.AddMonths(RangeEnd, -[Column1])), type date),
    #"Filtered Rows" = Table.SelectRows(Test, each [Test] > DateTime.Date(RangeStart) and [Test] <= DateTime.Date(RangeEnd))
in
    #"Filtered Rows"


image.png




Feel free to connect with me:
LinkedIn

@Smauro So I understand it correctly that the only trick you did was add the code below?

meta [IsParameterQuery=true, Type="DateTime", IsParameterQueryRequired=true]

Ahhh so it's this trick:

https://www.excelguru.ca/blog/2018/05/30/creating-dynamic-parameters-in-power-query/

 

Thanks!

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