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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
BuiltInThe80s
New Member

DateTime Minus 7 Days

Hi All,
I have two parameters, both with a DateTime value:

Param1: 11/05/2019 12:00:00
Param2: 11/05/2019 19:00:00

I am passing these parameters into a query (which requires the date and time as text) using the following:

Text.From(Param1)
Text.From(Param2)

This works fine but I would also like to do another query where it takes the parameters and takes off 7 days. I have tried the following but it doesn't seem to be working:

Text.From(Date.AddDays(DateTime.Date(Param1)), -7) & " " & Text.From(DateTime.Time(Param1))
Text.From(Date.AddDays(DateTime.Date(Param2)), -7) & " " & Text.From(DateTime.Time(Param2))

Expected output should be:

10/29/2019 12:00:00
10/29/2019 19:00:00

Any help appreciated.
2 REPLIES 2
Anonymous
Not applicable

Hi @BuiltInThe80s,

 

Please modify your formula as below:

Text.From(Date.AddDays([Param1],-7))

Result would be show as below:

1.PNG

Hopefully works for you.

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

Thanks @Anonymous 

 

This does work for a custom column but unfortunatley doesn't work in my query. A little more info: I am concatenating the query as text in my query. For example, the following is working for the date/time parameter:


& Text.From(Param1) &

& Text.From(Param2) &

 

Using your advice it looks like:

 

& Text.From(Date.AddDays([Param1],-7)) &

& Text.From(Date.AddDays([Param2],-7)) &

 

This gives me the following error:

 

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

 

Removing the square brackets doesn't give an error but also doesn't return any results. Any ideas?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.