Data Import and Transformation


Data Import and Transformation Interview with follow-up questions

1. Can you explain the process of data import in Power BI?

Data import in Power BI is the process of loading data from a source into the in-memory VertiPaq engine, where it is compressed and stored inside the semantic model for fast query performance. Import mode is one of three storage modes alongside DirectQuery and DirectLake.

Step 1: Connect to a data source In Power BI Desktop, click Get Data in the Home ribbon. Choose from hundreds of connectors: relational databases (SQL Server, PostgreSQL, Oracle, Snowflake), files (Excel, CSV, JSON, Parquet), cloud services (Azure, Salesforce, SharePoint, Fabric lakehouse/warehouse), and OData feeds. After selecting a connector, provide connection details and credentials.

Step 2: Select tables or write a query A navigator dialog shows available tables, views, or sheets. Check the items you want to import. For databases, you can write a native SQL query in advanced mode to pre-filter or join data at the source — this leverages query folding to reduce the data transferred to Power BI.

Step 3: Transform data in Power Query Clicking Transform Data opens the Power Query Editor. Apply transformation steps: filter rows, remove columns, rename headers, change data types, merge/append tables, pivot/unpivot, and handle nulls. All steps are recorded as M code and replayed on every refresh.

Step 4: Load into the semantic model Click Close and Apply to load the transformed data into Power BI's in-memory store. In the Model view, define relationships between tables, create DAX measures, and configure RLS.

Step 5: Configure refresh in the Service After publishing, scheduled refresh in the Power BI Service re-runs the Power Query steps and reloads the semantic model. Import-mode models reflect data only as of the last refresh.

Alternatives to full import:

  • DirectQuery — no data is imported; queries go live to the source on each visual interaction. Best for very large or frequently changing data where import latency is unacceptable.
  • DirectLake (Fabric only) — reads Delta/Parquet files directly from OneLake without a traditional refresh cycle, combining near-Import performance with near-real-time freshness.
  • Composite models — mix Import and DirectQuery tables in a single semantic model for balanced performance and freshness.
  • Incremental refresh — Import only new/updated rows each cycle while retaining historical partitions, dramatically reducing refresh duration for large tables.
↑ Back to top

Follow-up 1

What are the different data sources that Power BI supports?

Power BI supports a wide range of data sources, including:

  1. Databases: Power BI can connect to various databases such as SQL Server, Oracle, MySQL, and PostgreSQL.

  2. Files: Power BI can import data from files in formats like Excel, CSV, XML, JSON, and more.

  3. Online services: Power BI integrates with popular online services like SharePoint, Dynamics 365, Salesforce, Google Analytics, and more.

  4. Azure services: Power BI can connect to various Azure services like Azure SQL Database, Azure Data Lake Storage, Azure Blob Storage, and more.

  5. Web: Power BI can scrape data from websites using web connectors.

  6. Other sources: Power BI also supports other sources like OData feeds, Hadoop, SharePoint lists, and more.

Follow-up 2

How do you handle errors during data import?

Power BI provides several options to handle errors during data import:

  1. Error handling in Power Query: Power Query allows you to handle errors at the data transformation stage. You can choose to skip or replace error rows, or apply custom logic to handle errors.

  2. Error reporting: Power BI provides error reporting features that highlight any issues encountered during data import. These reports help you identify and resolve errors.

  3. Data profiling: Power BI includes data profiling capabilities that allow you to analyze the quality and consistency of your data. This helps in identifying potential errors or inconsistencies.

  4. Data refresh options: Power BI allows you to set up automatic data refresh options. If an error occurs during the refresh process, you can configure notifications or alerts to be notified about the error.

Follow-up 3

What is the role of Power Query in data import?

Power Query plays a crucial role in the data import process in Power BI. It is a data transformation and cleansing tool that allows you to connect to various data sources, shape and clean the data, and load it into Power BI.

Power Query provides a user-friendly interface for performing data transformations. It allows you to perform operations like filtering, sorting, merging, splitting, pivoting, and more. You can also create calculated columns and apply data type conversions.

Power Query also supports advanced features like data profiling, which helps in analyzing the quality and consistency of the data. It provides error handling options to handle errors during data import.

Overall, Power Query simplifies the process of data import by providing a unified and intuitive interface for connecting to data sources, transforming the data, and loading it into Power BI.

2. What is data transformation in Power BI and why is it important?

Data transformation in Power BI refers to the process of reshaping, cleaning, and enriching raw data so it is structured correctly for analysis in the semantic model. It is performed primarily in the Power Query Editor (using M code under the hood) before data is loaded into the model.

Why it is important:

  • Data quality — raw data from source systems often contains nulls, duplicates, inconsistent formats (e.g., dates stored as text, mixed-case strings), and errors. Transformation corrects these issues before they propagate into reports and mislead decision-makers.

  • Correct schema for modeling — the VertiPaq engine performs best when tables are structured in a star schema: narrow, clean dimension tables and fact tables without unnecessary columns. Transformation enables denormalizing, splitting, or restructuring tables to achieve this layout.

  • Performance — removing unused columns and filtering rows in Power Query reduces the volume of data loaded into memory. Fewer rows and columns means smaller model size, faster refresh, and snappier query performance.

  • Reusability and consistency — transformation logic defined in Power Query is centralized and replayed on every refresh. Unlike one-off Excel manipulations, the steps are self-documenting and repeatable.

Common transformation operations:

  • Filtering rows and removing columns not needed in the model
  • Changing data types (especially date/numeric columns mistyped as text)
  • Removing duplicates and handling null/error values
  • Splitting or merging columns (e.g., full name into first/last)
  • Pivoting and unpivoting tables
  • Merging (joining) queries and appending (stacking) queries
  • Creating conditional columns and grouping/aggregating data

Power Query vs. DAX: A key principle is to do row-reduction and schema work in Power Query, and business logic calculations (ratios, running totals, time intelligence) in DAX measures. Applying heavy transformations in DAX calculated columns is less efficient than doing equivalent work in Power Query, because DAX calculated columns are computed at model load time and stored, whereas Power Query operations can often be folded back to the source.

↑ Back to top

Follow-up 1

Can you give an example of a data transformation you have performed?

Sure! One example of a data transformation I have performed in Power BI is removing duplicates from a dataset. Let's say we have a dataset containing customer information, and there are duplicate records for some customers. To remove duplicates, I would use the 'Remove Rows' transformation operation in Power Query Editor. This operation allows me to specify the columns to check for duplicates and remove the duplicate rows from the dataset.

Follow-up 2

What are the common data transformation operations in Power BI?

There are several common data transformation operations in Power BI, including:

  1. Filtering: This operation allows you to filter rows based on specific criteria, such as removing rows with null values or filtering by a certain date range.

  2. Splitting and merging columns: You can split a column into multiple columns based on a delimiter, or merge multiple columns into a single column.

  3. Creating calculated columns: This operation allows you to create new columns based on calculations or expressions using existing columns.

  4. Removing duplicates: As mentioned earlier, you can remove duplicate rows based on one or more columns.

  5. Aggregating data: This operation involves grouping data by one or more columns and performing aggregations, such as sum, average, or count, on the grouped data.

These are just a few examples, and there are many more data transformation operations available in Power BI.

Follow-up 3

How does data transformation affect the performance of Power BI reports?

Data transformation can have a significant impact on the performance of Power BI reports. When performing data transformation operations, Power BI needs to process and manipulate the data, which can consume system resources and increase the time required to load and refresh the data. If the data transformation operations are complex or involve large datasets, it can lead to slower report performance.

To optimize the performance of Power BI reports, it is important to consider the following:

  1. Limit the number of data transformation operations: Only perform the necessary transformations and avoid unnecessary operations.

  2. Use efficient transformation techniques: Use techniques like query folding, which allows Power BI to push the data transformation operations back to the data source, reducing the amount of data transferred.

  3. Monitor and optimize query performance: Keep an eye on the query performance and optimize the queries used for data transformation.

By following these best practices, you can minimize the impact of data transformation on the performance of Power BI reports.

3. What is M Language and how is it used in Power BI?

M (officially called Power Query Formula Language) is the functional, case-sensitive language that runs behind every step in the Power Query Editor. When you apply a transformation in the GUI — filtering a column, changing a data type, merging two tables — Power BI writes M code for it. Advanced users read and write M directly to build transformations the GUI does not expose.

Key characteristics of M:

  • Functional and lazy — M is a functional language where expressions define what data should look like, not a sequence of imperative steps. Queries are only evaluated when data is loaded or previewed.
  • Structured expression language — everything in M is an expression that returns a value. Values can be primitive types (text, number, date, logical), or structured types (list, record, table).
  • Let…in syntax — M query logic is written as a let block that defines named steps, and an in clause that specifies the output of the query:
let
    Source = Sql.Database("server", "db"),
    Orders = Source{[Schema="dbo", Item="Orders"]}[Data],
    FilteredRows = Table.SelectRows(Orders, each [Status] = "Active"),
    RenamedColumns = Table.RenameColumns(FilteredRows, {{"OrderDate", "Date"}})
in
    RenamedColumns

How M is used in Power BI:

  • Automatic generation — every GUI action in the Power Query Editor appends an M step automatically. Most users never write M directly.
  • Advanced editor — the Advanced Editor (View > Advanced Editor) shows and allows editing of the full M query. This is used when you need logic the GUI cannot express, such as dynamic parameters, custom functions, or conditional branching.
  • Custom functions — reusable M functions can be created to apply the same transformation across multiple queries (e.g., a standardized date-parsing function).
  • Parameters — M parameters allow queries to be parameterized, enabling environment-switching (dev/test/prod server names) or date-range filtering without hardcoding values.
  • Query folding — M transformation steps that can be translated back into native source queries (SQL, OData, etc.) are "folded" to the source, so the filtering/aggregation happens at the database rather than in Power BI memory. Understanding which M operations fold and which break folding is important for performance tuning.

Gotcha interviewers probe: M is not the same as DAX. M runs at data load/refresh time in Power Query to shape data. DAX runs at query time in the semantic model to calculate measures and calculated columns. They serve different stages of the Power BI pipeline.

↑ Back to top

Follow-up 1

Can you write a simple M Language expression?

Sure! Here's an example of a simple M Language expression that calculates the sum of two numbers:

let
    a = 5,
    b = 10,
    sum = a + b
in
    sum

In this example, we define two variables a and b with values 5 and 10 respectively. We then calculate the sum of a and b and store it in the variable sum. Finally, we return the value of sum.

Follow-up 2

What are the advantages of using M Language for data transformation?

There are several advantages of using M Language for data transformation in Power BI:

  1. Flexibility: M Language provides a wide range of built-in functions and operators that allow users to perform complex data transformations and calculations.

  2. Reusability: M Language expressions can be saved as functions and reused across multiple queries, making it easy to standardize and automate data transformation processes.

  3. Performance: M Language is optimized for data transformation tasks, resulting in faster and more efficient data processing.

  4. Integration: M Language seamlessly integrates with other components of Power BI, such as Power Query Editor and DAX, allowing users to create end-to-end data transformation and analysis workflows.

Overall, M Language empowers users to efficiently transform and shape their data in Power BI, enabling them to gain valuable insights from their data.

Follow-up 3

How does M Language interact with other components of Power BI?

M Language interacts with other components of Power BI, such as Power Query Editor and DAX, to enable end-to-end data transformation and analysis workflows.

In Power Query Editor, M Language is used to define queries and transformations on data sources. Users can write M Language expressions to perform various data cleansing, shaping, and modeling operations on their data before loading it into Power BI.

Once the data is loaded into Power BI, users can use DAX (Data Analysis Expressions) to perform calculations, create measures, and build interactive visualizations. M Language and DAX work together to provide a comprehensive data transformation and analysis experience in Power BI.

Additionally, M Language can also be used to create custom functions and queries that can be shared and reused across multiple Power BI reports and dashboards.

Overall, M Language plays a crucial role in the data transformation and analysis process in Power BI, working in conjunction with other components to deliver powerful insights from data.

4. How do you handle large datasets during data import and transformation in Power BI?

Handling large datasets efficiently is one of the most practically important skills in Power BI, and interviewers probe this in depth. The strategies span storage mode selection, Power Query optimization, model design, and Fabric architecture.

1. Choose the right storage mode

  • Import — fastest query performance but requires the full dataset to fit in memory. Practical up to a few hundred million rows depending on cardinality and column count. Not suitable for multi-billion-row tables without aggressive aggregations.
  • DirectQuery — no data stored in Power BI; queries go to the source live. Works for any size but query performance depends on the source. Avoid complex DAX with DirectQuery as it generates inefficient SQL.
  • DirectLake (Fabric only) — reads Delta/Parquet files from OneLake directly without importing. Combines Import-level performance with near-real-time freshness, and scales to very large tables because it reads only the columns needed per query. The recommended mode for large datasets on Fabric.
  • Composite models — combine DirectLake or DirectQuery for large fact tables with Import-mode dimension tables to get fast filtering with live fact data.

2. Optimize Power Query for large imports

  • Apply filters early in the query steps to reduce row count before merges or type conversions.
  • Remove unused columns as early as possible to minimize data transferred and stored.
  • Ensure query folding is active — verify by right-clicking a step and checking whether "View Native Query" is available. Steps that do not fold pull all rows into memory and transform them in Power BI rather than at the source.
  • Avoid operations that break folding unnecessarily (e.g., certain custom column formulas or adding an index column early in the pipeline).

3. Use incremental refresh

Define an incremental refresh policy on large Import-mode tables to partition data by date range. On each refresh, only the recent partition (e.g., last 3 days) is reloaded, while historical partitions remain untouched. This reduces refresh duration from hours to minutes for tables with years of history. Incremental refresh requires Premium Per User (PPU) or Premium/Fabric capacity.

4. Aggregation tables

Create a pre-aggregated summary table (e.g., sales by month by region) alongside the full-grain fact table. Power BI automatically routes high-level queries to the fast aggregation table and falls through to the detail table only when a user drills to grain level. This technique, combined with a composite model, delivers interactive performance on billion-row datasets.

5. Semantic model design

  • Use a star schema — narrow dimension tables and a central fact table. Avoid wide flat tables with many low-cardinality repeated text columns (they compress poorly in VertiPaq).
  • Keep cardinality in check — high-cardinality text columns (free-form notes, URLs) inflate model size significantly; consider excluding them or summarizing.
  • Use integer surrogate keys for relationships rather than text keys; integer joins are faster and more memory-efficient.

6. Monitor with VertiPaq Analyzer / DAX Studio

Tools like DAX Studio and the open-source VertiPaq Analyzer report table and column sizes, cardinality, and relationship efficiency. Use them to identify which columns are consuming the most memory and where to focus optimization effort.

↑ Back to top

Follow-up 1

What are the limitations of Power BI in handling large datasets?

While Power BI is capable of handling large datasets, there are some limitations to be aware of:

  1. Memory Limitations: Power BI is limited by the available memory on the machine running the Power BI Desktop or the Power BI service. Large datasets may require more memory, and if the memory limit is exceeded, performance may be impacted.

  2. Data Refresh: Refreshing large datasets can be time-consuming, especially if the data source is remote or the dataset requires complex transformations. Power BI has a maximum refresh limit, and exceeding this limit may result in incomplete or failed refreshes.

  3. Data Import Options: While Power BI supports various data import options, each option has its limitations. For example, Import mode loads the entire dataset into memory, which may not be feasible for extremely large datasets.

  4. Data Transformation Complexity: Complex data transformations can impact performance, especially when dealing with large datasets. Power Query Editor may struggle to handle complex transformations efficiently.

  5. Visualizations: Power BI visualizations may experience performance issues when dealing with large datasets, especially if the visualizations involve complex calculations or interactions.

Follow-up 2

How do you optimize data import and transformation for large datasets?

To optimize data import and transformation for large datasets in Power BI, you can follow these best practices:

  1. Use DirectQuery or Live Connection: Instead of importing the entire dataset into Power BI, consider using DirectQuery or Live Connection to connect directly to the data source. This reduces the memory footprint and allows for real-time data access.

  2. Apply Filters and Remove Unnecessary Columns: Use filters to limit the amount of data being imported. Additionally, remove unnecessary columns that are not required for analysis to reduce the dataset size.

  3. Aggregate Data: If possible, aggregate the data at the source before importing it into Power BI. Aggregating data can significantly reduce the dataset size and improve performance.

  4. Use Query Folding: Power Query Editor supports query folding, which pushes data transformation operations to the data source. This can improve performance by reducing the amount of data transferred between Power BI and the data source.

  5. Optimize Data Types: Ensure that the data types of columns are optimized for storage and performance. For example, using smaller integer data types instead of larger ones can reduce memory usage.

  6. Partition Data: If your dataset is partitioned, consider importing and refreshing only the necessary partitions. This can improve refresh performance.

  7. Enable Parallel Loading: Power Query Editor allows you to enable parallel loading, which can speed up data import and transformation for large datasets.

Follow-up 3

What is the role of data compression in handling large datasets?

Data compression plays a crucial role in handling large datasets in Power BI. It helps in optimizing performance and reducing storage requirements. Here's how data compression works:

  1. Columnar Storage: Power BI stores data in a columnar format, which allows for efficient compression. Instead of storing data row by row, it stores values for each column together. This enables better compression ratios as similar values are grouped together.

  2. Compression Algorithms: Power BI uses compression algorithms to reduce the size of the data stored in memory. These algorithms identify repeating patterns and store them more efficiently. Different compression algorithms are used for different data types, such as integers, decimals, and strings.

  3. Dictionary Encoding: Power BI utilizes dictionary encoding to further compress data. It creates a dictionary of unique values in a column and replaces the actual values with dictionary references. This reduces the storage space required for repetitive values.

  4. Compression Trade-offs: While data compression reduces storage requirements, it also introduces a trade-off between storage and query performance. Highly compressed data may require more CPU resources to decompress during query execution. It's important to find the right balance between compression and query performance based on the specific requirements of your dataset.

5. Can you explain the process of data cleaning in Power BI?

Data cleaning in Power BI is the process of identifying and correcting errors, inconsistencies, and quality issues in raw data so it is reliable for analysis. The primary tool is the Power Query Editor, accessed in Power BI Desktop by clicking Transform Data after connecting to a source.

Common data cleaning tasks and how Power BI handles them:

Removing duplicates Use Remove Duplicates (Home ribbon or right-click a column) to eliminate duplicate rows based on all columns or a specific key column. This is commonly applied to dimension tables to ensure one row per entity.

Handling null and missing values Use Replace Values or Fill Down/Fill Up to address nulls. You can filter out rows where a critical column is null, replace nulls with a default value (e.g., "Unknown" for text, 0 for numbers), or use conditional columns to flag incomplete records for review.

Correcting data types Power Query auto-detects data types but is often wrong, especially for date and number columns stored as text in source files. Explicitly set data types for every column. Dates stored as text will not work correctly in DAX time intelligence functions until cast to the Date type.

Standardizing text Use Transform > Format options: Trim (remove leading/trailing spaces), Clean (remove non-printable characters), UPPERCASE, lowercase, or Proper Case. Inconsistent casing (e.g., "New York" vs "new york" vs "NEW YORK") causes grouping errors in visuals.

Splitting and combining columns Split a single column (e.g., "First Last" full name, or "City, State" combined fields) into separate columns using delimiter-based or positional splitting. Conversely, merge columns with a custom separator.

Replacing incorrect values Use Replace Values to fix known bad data — for example, replacing "N/A" text with null, or correcting a misspelled category name that appears consistently in the source.

Filtering out irrelevant rows Remove test records, header rows embedded mid-file, or out-of-scope data early in the query to reduce model size and avoid contaminating aggregations.

Handling errors Power Query surfaces errors at the cell level (e.g., a type conversion that failed). Use Remove Errors to drop those rows, or Replace Errors to substitute a default value, depending on the business requirement.

Column quality profiling The Power Query Editor's column profiling tools (View > Column quality / Column distribution / Column profile) show the percentage of valid, null, and error values per column, along with value distribution histograms. This makes it easy to spot quality problems before loading data into the model.

Key principle for interviews: data cleaning is best done in Power Query rather than in DAX, because Power Query transformations run at refresh time and reduce the data entering the model. Cleaning data with DAX calculated columns is technically possible but wastes memory by storing the corrected values alongside the original bad data.

↑ Back to top

Follow-up 1

What are the common data cleaning operations in Power BI?

Some common data cleaning operations in Power BI include:

  1. Removing duplicate records: Power BI provides a 'Remove Rows' function in the Query Editor to eliminate duplicate rows based on selected columns.

  2. Handling missing values: Power BI allows you to replace or remove missing values using functions like 'Replace Values' or 'Remove Rows' in the Query Editor.

  3. Correcting data types: Power BI enables you to change the data type of a column using the 'Change Type' function in the Query Editor.

  4. Standardizing formats: Power BI provides functions like 'Format' or 'Trim' in the Query Editor to standardize the format of text or numeric values.

  5. Resolving inconsistencies: Power BI allows you to merge or split columns, combine data from multiple sources, or use conditional logic to resolve inconsistencies in the data.

Follow-up 2

How does data cleaning affect the quality of Power BI reports?

Data cleaning plays a crucial role in ensuring the quality and accuracy of Power BI reports. By cleaning the data, you can eliminate errors, inconsistencies, and inaccuracies that can lead to incorrect insights and analysis. Clean data improves the reliability of your reports, enhances data visualization, and enables more accurate decision-making. It also helps in avoiding data-related issues such as incorrect aggregations, misleading visualizations, and incorrect calculations.

Follow-up 3

Can you give an example of a data cleaning challenge you have faced and how you solved it?

One example of a data cleaning challenge I have faced is dealing with inconsistent date formats. In the dataset, the date column had different formats such as 'MM/DD/YYYY' and 'YYYY-MM-DD', which caused issues when performing date-based calculations and visualizations. To solve this, I used the Query Editor in Power BI to standardize the date format by splitting the column into day, month, and year components, and then combining them into a consistent 'YYYY-MM-DD' format. This ensured that the date data was clean and consistent, allowing for accurate analysis and visualization in Power BI.

Live mock interview

Mock interview: Data Import and Transformation

Intermediate ~5 min Your own free AI key

Your voice and your AI key never touch our servers; the key stays in this browser and is sent only to Google. Only your round scores are saved to track progress.

Next lesson Data Analysis Expressions (DAX) →