How to clean messy data in Power BI with AI and Power Query

You will learn how to use an AI assistant to build a Power Query cleanup in Power BI, then check and fix the generated code. It suits Excel and Power BI users who already know the basics of importing data. You need Power BI Desktop, a folder of messy files and access to an AI chat tool.

I Let AI Clean My Messy Data, Here’s What Happened, by Goodly on YouTube. 18 min 15 s.

5 chapters. Tap a step to jump to it.Chapters from the creator
Video length
18 min 15 s
Time to do it
45 minutes
Difficulty
Medium
Steps
8

What you need

Steps

  1. Put all your messy files in one folder and note the exact folder path. Keep the file names and column headers consistent so the query can combine them.

  2. Open Power BI Desktop and start a blank report. Go to Get data, choose Folder, and point it at your data folder so Power Query lists the files.

  3. Open your AI chat tool and paste a short prompt describing the cleanup. Ask it to write Power Query M code that combines the files and fixes dates and column names.

  4. Copy the generated M code into a blank query in the Power Query Advanced Editor. Click Done and check that the preview table loads without errors.

  5. Read the code line by line. Look for a hard-coded folder path, fixed column names and steps that are not needed, and replace the path with a parameter or the folder connector.

  6. Test the date conversion on a few known rows. Compare the output to the original file so a wrong format does not pass unnoticed.

  7. Remove unnecessary steps and rewrite the query in a shorter form. Keep one clear step per change so you can trace any error.

  8. Click Refresh and confirm the table updates with the right row count and values. Save the Power BI file once the refresh is clean.

Tips and common mistakes

A query can refresh without errors and still give wrong dates, so always spot-check the output against the source.

Hard-coded folder paths break when the file moves, so use a parameter for the path.

Ask the AI to explain each step before you paste the code, then delete anything you do not understand.

Keep a copy of the original files so you can compare results after each change.

Questions

Can AI write the whole Power Query for me?

It can produce a working starting point, but you still need to review the code. Check paths, column names and date conversions before you trust the refresh.

Why does my query show the wrong dates?

The conversion likely used the wrong locale or format. Set the data type and locale explicitly in the Changed Type step and test a few rows.

Do I need to know M code to do this?

Basic reading helps a lot. You can start from the AI output and learn the steps in the Advanced Editor as you fix them.

This guide was drafted from the video's details and general task knowledge. It has not been checked against the full video. Check the video and relevant product instructions before following a procedure. Report a correction.

More in Money & Office

See all