Automatically Assign a Category to Uncategorized Rows in Power Query and DAX

Learn how to automatically assign categories to uncategorized rows in Power Query and DAX to improve reporting and data aggregation.

domingo, 26 de julio de 2026 • 4 min read • Q2BSTUDIO Team

Cómo categorizar datos no clasificados en Power Query y DAX

In today's Business Intelligence world, uncategorized data is one of the biggest challenges for analytics teams. Without consistent categories, it is impossible to group, aggregate, or generate meaningful reports. However, we often encounter rows that lack an assigned category, whether due to capture errors, incomplete migrations, or the dynamic nature of the data. In this article we will explore how to automatically assign categories to those orphan rows using two powerful tools: Power Query (M) and DAX. We will see practical examples, best practices, and how companies like Q2BSTUDIO integrate these techniques into BI solutions and custom software.

Imagine a typical scenario: an asset database in a facility management company where some records have no defined category (e.g., 'office', 'warehouse', 'server room'). Without that category, reports on occupancy, maintenance, or costs remain incomplete. The solution is not to manually correct each row but to create intelligent rules that assign the category based on other available fields, such as asset name, location, or department. Power Query is excellent for ETL transformations, while DAX enables dynamic calculations in the tabular model.

Power Query: conditional rule approach

In Power Query we can create a conditional column that evaluates the content of other columns to assign the category. For example, if the 'Name' field contains 'server' or 'rack', assign 'Server Room'; if it contains 'desk' or 'chair', assign 'Office'. This can be done easily through the Power Query interface or with M code. But when rules are complex or come from an external mapping table, it is more efficient to use a custom function that performs a fuzzy or exact lookup. For instance, we can load a synonyms table ('server' -> 'Server Room', 'desk' -> 'Office') and then use Table.Join or Merge Queries to match uncategorized rows with the correct category. This fully automates the process and reduces errors.

DAX: dynamic calculation in the model

Once data is loaded into Power BI, we can use DAX to assign categories in real time, especially if the rules depend on other model data or parameters. A common practice is to create a calculated column with the SWITCH function and logical conditions. For example: Categoría = SWITCH(TRUE(), CONTAINSSTRING(Activos[Nombre], 'servidor'), 'Sala de Servidores', CONTAINSSTRING(Activos[Nombre], 'escritorio'), 'Oficina', ...). We can also use LOOKUPVALUE to get the category from a reference table, or use functions like CALCULATE and FILTER for more advanced cases. The advantage of DAX is that we can modify rules without reprocessing data, ideal for agile environments.

Integration with cloud and automation

In enterprise projects, these techniques are often combined with cloud infrastructure (AWS/Azure) and automated processes. For example, a data pipeline that runs Power Query in Azure Data Factory, applies categorization rules, and then sends the result to Power BI. Additionally, AI agents can learn patterns and suggest new rules, continuously improving data quality. Q2BSTUDIO offers automation services and custom software development, helping companies implement these solutions robustly and scalably.

Performance and security considerations

When automatically assigning categories, it is crucial to optimize performance, especially with millions of rows. In Power Query, avoid too many nested conditions; instead use merges with indexed tables. In DAX, calculated columns are materialized in the model, so consider whether using measures that calculate the category on the fly is better. On the other hand, cybersecurity must ensure that sensitive data (like server locations) is not exposed. Cloud solutions from Azure and AWS offer encryption and access control, and at Q2BSTUDIO we integrate cybersecurity practices into all our developments.

Complete example with Power Query and DAX

Suppose we have an 'Assets' table with columns: ID, Name, Location, Category (many blank). We create a mapping table 'Categorization' with keywords and their associated category. In Power Query, we perform a Merge between Assets and Categorization using a function that checks if the Name contains any keyword. Then we expand the category column and fill gaps with 'Uncategorized'. In DAX, we create a calculated column that uses the loaded mapping table: Categoría DAX = LOOKUPVALUE(Categorizacion[Categoría], Categorizacion[PalabraClave], LEFT(Activos[Nombre], 10)). Adjust as needed.

Conclusions and next steps

Automatic category assignment not only saves time but also improves report accuracy and allows analysts to focus on strategic decisions. Combining Power Query for initial transformation and DAX for dynamic adjustments, we can handle even the messiest datasets. If your organization faces similar challenges, at Q2BSTUDIO we develop custom applications and AI solutions that integrate these techniques with cloud, cybersecurity, and BI. Feel free to contact us to transform your data into strategic assets.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.