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
jeongkim
Post Prodigy
Post Prodigy

Filter out date values before year 2000

Hi,

 

How can I filter in Query that if the date values before year 2000 then replace to null value? 

FYI, sometimes raw data has values with 1900-01-01 which is actually no value so I wanna filter them out as blank. 

 

jeongkim_0-1741850670220.png

 

3 ACCEPTED SOLUTIONS
freginier
Super User
Super User

Hey there!

 

To filter out date values before the year 2000 and replace them with null values in Power Query (M Language), follow these steps:

 

Create a Custom Column

  • Click on Add ColumnCustom Column.
  • Enter the following M Code:
NewDateColumn = Table.AddColumn( YourTable, "Filtered Date", each if [YourDateColumn] < #date(2000, 1, 1) then null else [YourDateColumn], type nullable date )
 

Replace the Old Column (Optional)

  • If you want to replace the existing date column, modify it directly:

YourTable = Table.TransformColumns(
YourTable,
{{"YourDateColumn", each if _ < #date(2000, 1, 1) then null else _, type nullable date}}
)

 

Hope this helps!

😁😁

View solution in original post

You need to change the first parameter to the name of the previous step, looks like should be "Source" in your case

Deku_0-1741856457528.png

Table.TransformColumns(
#"Source",
{{"준공예정일자", each if _ < #date(2000, 1, 1) then null else _, type nullable date}}
)

Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

You need to specify each column but can be in the same operation 

= Table.TransformColumns(
#"TOSS",
{{"준공예정일자", each if _ < #date(2000, 1, 1) then null else _, type nullable date},
{"Column1", each if _ < #date(2000, 1, 1) then null else _, type nullable date}}
)

Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

10 REPLIES 10
Deku
Super User
Super User

Table.ReplaceValue(#"Table",each if Date.Year([Date Schedule Start]) < 2000 then [Date] else false ,null,Replacer.ReplaceValue,{"Date"})


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
freginier
Super User
Super User

Hey there!

 

To filter out date values before the year 2000 and replace them with null values in Power Query (M Language), follow these steps:

 

Create a Custom Column

  • Click on Add ColumnCustom Column.
  • Enter the following M Code:
NewDateColumn = Table.AddColumn( YourTable, "Filtered Date", each if [YourDateColumn] < #date(2000, 1, 1) then null else [YourDateColumn], type nullable date )
 

Replace the Old Column (Optional)

  • If you want to replace the existing date column, modify it directly:

YourTable = Table.TransformColumns(
YourTable,
{{"YourDateColumn", each if _ < #date(2000, 1, 1) then null else _, type nullable date}}
)

 

Hope this helps!

😁😁

Sorry not working

 

jeongkim_0-1741855955923.png

 

= Table.TransformColumns(
#"TOSS 데이터_공사목록 - Append",
{{"준공예정일자", each if _ < #date(2000, 1, 1) then null else _, type nullable date}}
)

You need to change the first parameter to the name of the previous step, looks like should be "Source" in your case

Deku_0-1741856457528.png

Table.TransformColumns(
#"Source",
{{"준공예정일자", each if _ < #date(2000, 1, 1) then null else _, type nullable date}}
)

Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

thanks now is working, 

can we apply this to all date columns? or shoud I name it column by column in the code? 

You need to specify each column but can be in the same operation 

= Table.TransformColumns(
#"TOSS",
{{"준공예정일자", each if _ < #date(2000, 1, 1) then null else _, type nullable date},
{"Column1", each if _ < #date(2000, 1, 1) then null else _, type nullable date}}
)

Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

do you know reason I cannot filter in order?

 

jeongkim_0-1741857710719.png

 

jeongkim_1-1741857962456.png

jeongkim_2-1741857978350.png

 

= Table.TransformColumns(
#"Sorted Rows1",
{{"준공신고서제출일자", each if _ < #date(2000, 1, 1) then null else _, type nullable date}}
)

works for me

Deku_0-1741857912552.png

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

I think that code got error when initial value is null. 

Can we create 2 conditions:

 

1. if value null then null.

2. if value before year 2000 then null.

 

if value doesn't meet above conditions then keep it as it is. 

 

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.