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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jtomczyk
Helper I
Helper I

Date Filter in Power Query

Hallo, 

I would like to have one button to remove all projects that were done in last 30 days.

To do that I have added new conditional column in power query. I do not know why it doesn't work. Any idea?

= Table.AddColumn(#"Replaced Value8", "YYY", each if [Date] < Date.AddDays(DateTime.LocalNow(),-30) then "Wrong" else "Correct")

jtomczyk_0-1649079368447.png

 

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

Hi., @jtomczyk ;

Because your [Date] column is in Date format and date.adddays (datetime.localnow (), -30) returns Date/Time format, the two formats are not comparable in power Query, so you cannot use <;

vyalanwumsft_0-1649305539029.pngvyalanwumsft_1-1649305564304.png

so we could change the Date column to Date/Time format . then compare them.

vyalanwumsft_2-1649305616072.png

= Table.AddColumn(#"Changed Type1", "Custom", each if [Date]<Date.AddDays(DateTime.LocalNow(),-30) then "Wrong" else "Correct")

Or change the other column to Date format.


Best Regards,
Community Support Team _ Yalan Wu
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-yalanwu-msft
Community Support
Community Support

Hi., @jtomczyk ;

Because your [Date] column is in Date format and date.adddays (datetime.localnow (), -30) returns Date/Time format, the two formats are not comparable in power Query, so you cannot use <;

vyalanwumsft_0-1649305539029.pngvyalanwumsft_1-1649305564304.png

so we could change the Date column to Date/Time format . then compare them.

vyalanwumsft_2-1649305616072.png

= Table.AddColumn(#"Changed Type1", "Custom", each if [Date]<Date.AddDays(DateTime.LocalNow(),-30) then "Wrong" else "Correct")

Or change the other column to Date format.


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

 

amitchandak
Super User
Super User

@jtomczyk , what we do is we had a filter in power query with the static date on the data then go and replace the static date with this one

Date.AddDays(DateTime.LocalNow(),-30)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hallo @amitchandak 

For the static date it works

jtomczyk_0-1649080407424.png

when I replace that date with Date.AddDays(DateTime.LocalNow(),-30) I get error to all values

jtomczyk_1-1649080456869.png

 

jtomczyk_2-1649080616663.png

 

 

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.