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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors