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
virus190
Helper II
Helper II

Replace duration with parameter

Hi,

 

im using #duration(0,7,30,0) in my Power Query. But i want it to be a parameter.

 

Now:

Table.AddColumn(#"Changed Typ", "WorkingDay", each [Date]- #duration(0,7,30,0))


I tried:

- creating a parameter with time = 0,7,30,0 and then using it in Power Query --> #duration(time) 

- creating a parameter with time = #duration(0,7,30,0) and then using it in Power Query --> time

didnt work.

 

What did work:

- creating a paramter with time = 7 and then using it in Power Query --> #duration(0,time,30,0)


But i want both, hour and time to be a paramater. Is there a better way then using 2 parameter?

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @virus190 

Create three blank queries, enter codes in Advanced editor,

hour list

let
    Source = {1..24}
in
    Source

minutes list

let
    Source = {0..59}
in
    Source

day list

let
    Source = {0..30}
in
    Source

 

Then create three parameters

Capture2.JPGCapture3.JPG

Use parameter in table

Capture1.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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
v-juanli-msft
Community Support
Community Support

Hi @virus190 

Create three blank queries, enter codes in Advanced editor,

hour list

let
    Source = {1..24}
in
    Source

minutes list

let
    Source = {0..59}
in
    Source

day list

let
    Source = {0..30}
in
    Source

 

Then create three parameters

Capture2.JPGCapture3.JPG

Use parameter in table

Capture1.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jimmy801
Community Champion
Community Champion

Hello

 

Create a new blank query and name it like you want the parameter to be named. Then go to the advanced editor and paste in this code. This should do the trick

(#duration(0,7,30,0)) meta [IsParameterQuery=true, Type="Any", IsParameterQueryRequired=true]

you can then apply your parameter using a Syntax like

DateTime.LocalNow() + YouParameterName


If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

Hello,

 

thank you very much. This does work.

 

But i want that the user to be able to change the duration from the parameter. Thats the goal.

 

Like this:

Example 


But change it from 7,30 to maybe 8,00


Is this possible?

 

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