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
Anonymous
Not applicable

Replace values of date column in entire table using M query

Hi folks,

I am trying to replace "0000000" with "null"  in date column before changing its data type to Date.

I have more than 10 Date columns."Replace values" works column wise not for entire table or for selected column.

I want to repeat below M code  for 10 columns .

#"Replaced Value" = Table.ReplaceValue(#"Added Items","00000000",null,Replacer.ReplaceValue,Table.ColumnNames{#"Added Items"})

 

Can any one suggest how can I handle this in PQ.

 

Thank you in advance.

 

1 ACCEPTED SOLUTION
ibarrau
Super User
Super User

Hi. Creating something really automatic like that will take some time. We can work in improving but for now I think this will work. Just add columns in a single transformation:

 

= Table.ReplaceValue(#"LastStep",00000000,null,Replacer.ReplaceValue,{"Column1", "Column2", "ColumnN"})

 

That will work. Then if you want to add all columns with "date" type you can build a list like this to replace the text in { }.

 

= Table.ToList(Table.SelectColumns(Table.SelectRows(Table.Schema(STEPTABLENAME), each [Kind] = "date"), "Name"))

 

 Hope this helps,

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

View solution in original post

2 REPLIES 2
dax
Community Support
Community Support

Hi @Anonymous , 

You could refer to @ibarrau 's suggestions, just add column names in it like below

= Table.ReplaceValue(#"Added Items","00000000",null,Replacer.ReplaceValue,{"column1", "column2"})

Because the 000000 is text type, so you need to change @ibarrau 's expression to "00000".

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

ibarrau
Super User
Super User

Hi. Creating something really automatic like that will take some time. We can work in improving but for now I think this will work. Just add columns in a single transformation:

 

= Table.ReplaceValue(#"LastStep",00000000,null,Replacer.ReplaceValue,{"Column1", "Column2", "ColumnN"})

 

That will work. Then if you want to add all columns with "date" type you can build a list like this to replace the text in { }.

 

= Table.ToList(Table.SelectColumns(Table.SelectRows(Table.Schema(STEPTABLENAME), each [Kind] = "date"), "Name"))

 

 Hope this helps,

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

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