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
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
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