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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

How to recode date by M code when user data entry mistake ?

Hi All

 

My CSV file have data entry mistake , the date should 04/01/2017 but user enter wrongly .

Paulyeo11_0-1604112688483.png

Can some one share how to recode the date ?

Paulyeo11_1-1604113330619.png

My PBI file :-

https://www.dropbox.com/s/nafv47zueysvzv7/Change%202030%20to%202017%20V002.pbix?dl=0

 

Paul Yeo

9 REPLIES 9
v-jingzhang
Community Support
Community Support

Hi @Anonymous , please refer to the image below.

11041.jpg

Best regards,

Jing

Anonymous
Not applicable

Hi Jing

That is good suggestion. in case one of the invoice sales staff enter the wrong date , and this date we have 20 invoice , how to change the date link to invoice numner ?

Paul 

@Anonymous With this replace values function, it will replace all the same wrong date in the selected date column with the correct one no matter what invoices they are linked to. 

Jing

Anonymous
Not applicable

Hi Sir

Assume today on 04/11/2020 , there are 100 invoice , and one of the invoice date error entry enter as 11/04/2020 , and during 11/04/2020 which is april  , also have 1-- invoice , will all also change to 04/11/2020 ?

Paul

@Paulyeo11

Yes, it will replace everything.

If you want to replace the specific linked to an invoice number, you can add the following M code in the Advanced Editor. Remember to change the names of the steps in the M code based on the names of the steps.

#"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [date],each if [inv]=110102 and [date]=#date(2030,1,4) then #date(2017,1,4) else [date],Replacer.ReplaceValue,{"date"})

11048.jpg

Best regards

Jing

Anonymous
Not applicable

Hi Jing 

this make sense

paul

Anonymous
Not applicable

@Anonymous -You can replace it with the correct date in Power Query.

Anonymous
Not applicable

Hi Sir

Can you pls share with me how to write M code , if INV = 110102 and date = 04 January 2030 , Replace by 04 January 2017 . 
Paul

Just highlight the Date column in the query editor and click on Replace Values in the ribbon, put 1/4/2030 in first cell and 1/4/2017 in second (assuming you have no rows where 1/4/2030 would be the correct value).

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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