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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
naoyixue1
Post Patron
Post Patron

How to replace the text with last week date in Power Query

Hey! I'm now trying to replace the text with last week date in power query, but failed. (see below exact changes I made)

 

Any thoughts? Thanks!

 

That's what I originally used to replace the text with today date. 

 

Date.ToText(Date.From(DateTime.LocalNow()))

 

naoyixue1_0-1690994137271.png

 

Here is what I tried to replace with last week date, but failed 

 

Date.AddDays(Date.From(DateTime.LocalNow())),-7)

 

naoyixue1_1-1690994283109.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @naoyixue1 ,

 

I think -7 should in Date.AddDays function. Please try code as below.

= Table.ReplaceValue(#"Filtered Rows3","Past",Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),-7)),Replacer.ReplaceValue,{"Week"})

Result is as below.

vrzhoumsft_0-1691386213582.png

 

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @naoyixue1 ,

 

I think -7 should in Date.AddDays function. Please try code as below.

= Table.ReplaceValue(#"Filtered Rows3","Past",Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),-7)),Replacer.ReplaceValue,{"Week"})

Result is as below.

vrzhoumsft_0-1691386213582.png

 

Best Regards,
Rico Zhou

 

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

 

jdbuchanan71
Super User
Super User

@naoyixue1 

I think you have an extra ')' in your new line.

Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow())),-7)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors