How to Map Free Text Data into Pre-Defined Values in Power BI

In today’s data-driven world, businesses generate enormous amounts of data, including free-text data. However, to make sense of such data, it is important to map these free-text data into pre-defined values — Power BI offers such a possibility.

While mapping text data into values can be challenging, and requires technical know-how for execution, this article will explore the steps you can take to easily map free-text data into pre-defined values in Power BI.

Let’s get started.

Understand the Importance of Data Mapping

Generally, data mapping is a crucial step in the data analysis process, as it allows you to transform unstructured data into a more organized and structured format.

Hence, by mapping free text data into pre-defined values or categories, you can easily gain valuable insights and make more informed decisions based on your data.

However, without proper data mapping, your analysis may be incomplete or inaccurate, and can lead to incorrect conclusions and ineffective business decisions.

Identify the Free Text Data

To effectively map free-text data into pre-defined values in Power BI, it is important to first identify which columns or fields in your dataset contain text-based data.

To do this, examine the data pattern and identify any columns or fields that contain free-text data such as product names, customer names, location, etc.

It is also important to consider the quality and consistency of the text data you are working with. Any data that is incomplete, misspelled, or contains typos may require further data cleaning before it can be mapped to pre-defined values.

Define the Pre-defined Values

The next thing to do is to define the set of pre-defined values to which the free text data will be mapped. The goal of this step is to identify the patterns and groupings within the text data and assign them to specific values for analysis.

For example, in a dataset containing product names, it may be helpful to map these names to a smaller set of product categories such as electronics, clothing, or food.

NB: Ensure these values are unique, consistent, and cover all possible categories of the free text data.

Create a Mapping Table

To start mapping free text data into pre-defined values, create a mapping table. This table should have two columns: one for the free text data and one for the pre-defined value or category that it should be mapped to.

You can create this table manually or import it from sources such as a CSV file, database, etc. Once you have this table, you can now use it to create a relationship between your free text data and the pre-defined values in Power BI.

How to Use Power Query to Map Your Data

Power Query is a tool in Power BI that can help you map your free text data into pre-defined values. To use Power Query, import the data you want to map into Power BI. Then click on “Transform Data” in the “Home” tab to open up the Power Query Editor.

From here, you can use the “Replace Values” or “Group By” function to map your free text data into pre-defined values.

Using the “Replace Values” Function

You can use the “Replace Values” function to replace the free text data with the pre-defined values. To do this, select the column containing the free text data, then click on “Replace Values” in the “Transform” tab.

In the “Replace Values” dialog box, select the mapping table you created, then enter the free text value you want to map and the pre-defined value you want to map it to, then click on “OK”

Once you map all of your data, you can load it back into Power BI and start analyzing your data.

Using the “Group By” Function

Another way to map free text data into pre-defined values is to use the “Group By” function. To use this function, create a new column in your data set that contains the pre-defined values.

Once you create the new column, use the “Group By” function to group the data by the pre-defined values.

How to Use DAX Formulas to Map Your Data

In addition to using Power Query, you can also use DAX formulas to map your free text data into pre-defined values in Power BI.

Using the SWITCH Function

The SWITCH function works by evaluating an expression and returning a result based on a set of conditions. Here’s an example:

Mapped_Value =
SWITCH (
   [Original Value],
   "Product X", "Electronics",
   "Product Y", "Clothing",
   "Product Z", "Food",
   "Other"
)

Here, the SWITCH function evaluates the value in the “Original Value” column and returns the corresponding mapped value from the mapping table.

If the value in the “Original Value” column does not match any of the values in the mapping table, the function will return “Other”.

Using the LOOKUPVALUE Function

The LOOKUPVALUE function searches a table for a value and returns corresponding values from another column in the same table. Below is an example:

Mapped_Value =
LOOKUPVALUE (
   MappingTable[Mapped Value],
   MappingTable[Original Value], [Original Value]
)

In this example, the LOOKUPVALUE function searches the “MappingTable” for the value in the “Original Value” column and returns the corresponding mapped value from the “Mapped Value” column.

Using the RELATED Function

The RELATED function returns the related value from another table based on a common column. Here’s an example:

Mapped_Value = RELATED ( MappingTable[Mapped Value] )

Here the RELATED function returns the related mapped value from the “MappingTable” based on a common column between the two tables.

Test and Refine your Mapping

Finally, once you are done mapping your free text data into pre-defined values, it is important to test and refine your mapping to ensure accuracy.

To do this, create visualizations that let compare your mapped data to the original free-text data. Also, you can gather feedback from other users or stakeholders to ensure that your mapping accurately reflects their understanding of the data.

Conclusion

In this article, I have explored different techniques for mapping free text data into pre-defined values, including creating a mapping table, using the Power Query Editor, and the DAX formulas.

By following these techniques, you can transform your free text data into structured data that can be easily analyzed and visualized in Power BI.

If you enjoyed reading this article, you can also check how to create a custom map in Power BI like a pro.

Happy analyzing!