top of page
Writer's pictureNaveen Mechu

Common mistakes to avoid when working with Power Query in Power BI

Updated: Apr 29, 2023

When using Power Query to load data into Power BI, you may encounter errors that prevent you from analyzing your data. These errors can be frustrating, but they are often easy to fix once you understand their causes. In this blog post, we'll discuss some of the common errors you may encounter while loading data in Power Query and how to fix them.

1. Incorrect data types

One reason for this is that Power Query uses a process called "type inference" to determine the data type of each column in a table when it first loads data. This process involves analyzing a subset of the data, typically the first 1000 rows, to determine the data type of each column.

Power Query uses a process called "type inference" to determine the data type of each column in a table when it first loads data. If the initial type inference is incorrect, it can cause errors when performing subsequent operations on the data, such as merging tables or calculating new columns. Therefore, it's important to review the data types assigned by Power Query and manually adjust them if needed.

In below example taken same three columns- A, B, & C. Till column 1178 added numeric data in A, Text data in B and in C added mix. After that added 22 records where in column A added text, B numeric and C mix. It will give below error.



To adjust the data type of a column in Power Query, you can select the column and then use the "Data Type" button in the "Transform" tab to select the appropriate data type. Alternatively, you can use the "Detect Data Type" button to re-run the type inference process on the selected column.


2. Data formatting issues

In addition to incorrect data types, formatting issues such as blank rows or columns, extra spaces, or invalid characters can cause errors in Power Query. These issues can often be resolved by using the "Remove Rows" or "Trim" functions in the Transform tab.

Added special symbol- & in some rows to show this.




3. Data source connectivity issues

Sometimes, errors can occur due to connectivity issues with the data source, such as network or authentication errors. In such cases, it's important to ensure that the data source is properly configured and that you have the necessary permissions to access the data.


4. Query syntax errors

Syntax errors in your Power Query code can also cause errors when loading data. These errors can often be resolved by reviewing the code and correcting any syntax errors or missing or extra parentheses or commas.


5. Data volume issues

Large data volumes can sometimes cause issues with Power Query, such as slow performance or timeouts. In such cases, it may be necessary to optimize your queries, such as by filtering or aggregating the data before loading it.


In addition to understanding the causes of errors in Power Query, it's also helpful to be familiar with the error messages that you may encounter. Here are some common error messages you may see while loading data in Power Query, along with their possible causes:


1. "Expression.Error: We cannot apply operator & to types Text and Number."

This error occurs when you try to concatenate a text string with a numeric value. To fix this error, you can convert the numeric value to text using the "Text.From" function.


2. "DataSource.Error: ODBC: ERROR [HY000] [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt."

This error occurs when you try to execute a new query while another query is still running. To fix this error, you can wait for the first query to complete before running the second query, or you can adjust the "Max Degrees of Parallelism" setting to limit the number of concurrent queries.


3. "Expression.Error: The column 'X' of the table wasn't found."

This error occurs when you reference a column that doesn't exist in the table. To fix this error, you can check the spelling of the column name and make sure it exists in the table.


4. "Expression.Error: The name 'X' wasn't recognized. Make sure it's spelled correctly."

This error occurs when you reference a variable or function that doesn't exist in your query. To fix this error, you can check the spelling of the variable or function name and make sure it exists in your query. You can also check that any external references are correctly spelled and properly configured.


5. "DataSource.Error: The operation has timed out."

This error occurs when a query takes too long to execute and times out. To fix this error, you can try optimizing your query by filtering or aggregating the data before loading it. You can also adjust the "Command Timeout" setting in the data source options to allow for longer query execution times.


6. "Expression.Error: The name 'Table.TransformColumnTypes' wasn't recognized. Make sure it's spelled correctly."

This error occurs when you try to use a function that is not recognized by Power Query. To fix this error, you can check the spelling of the function name and make sure it is a valid Power Query function.


7. "Expression.Error: The key didn't match any rows in the table."

This error occurs when you try to join two tables using a key that does not exist in one of the tables. To fix this error, you can check the spelling of the key column name and make sure it exists in both tables.


Conclusion: By understanding the common causes and error messages in Power Query, you can more easily identify and resolve errors when loading data into Power BI. Additionally, it's important to always test your queries thoroughly to ensure that they are working as intended and to monitor your data sources for any changes that may impact your queries. By following these best practices, you can ensure that your data is accurate and reliable for analysis in Power BI.

1,029 views0 comments

Comments


bottom of page