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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors