Code Generator | DAX

Creating a Combined Column in DAX

This task involves combining two existing columns in a table using DAX. The "COMBINEVALUES" function is used to create a new calculated column by concatenating the values of the specified columns with a separator.


Empty image or helper icon

Prompt

combine column Itemno.1 and column Trim from Table Label Reorder Summary for each row

Answer

Indeed, this is a simple and common task in DAX where we need to create a new column by combining two existing columns (in this case, "Itemno.1" and "Trim" from the "Label Reorder Summary" table). To combine two text fields, we can use the "COMBINEVALUES" function in DAX. Here's how you can create this calculated column:

// Add a new column named "Combined" to "Label Reorder Summary" table
Label Reorder Summary[Combined] = 
COMBINEVALUES(" - ", 'Label Reorder Summary'[Itemno.1], 'Label Reorder Summary'[Trim])

Let's break down the code:

COMBINEVALUES(" - ", 'Label Reorder Summary'[Itemno.1], 'Label Reorder Summary'[Trim]) creates a string by combining 'Label Reorder Summary'[Itemno.1] and 'Label Reorder Summary'[Trim] separated by " - ".

Label Reorder Summary[Combined] = assigns the result string as a new column "Combined" in the "Label Reorder Summary" table.

You can adjust the separator and columns to suit your needs. Ensure the 'Label Reorder Summary'[Itemno.1] and 'Label Reorder Summary'[Trim] columns exist in your 'Label Reorder Summary' table.

Please note: Make sure the 'Label Reorder Summary'[Itemno.1] and 'Label Reorder Summary'[Trim] columns are in text format. If not, you will need to convert them using the FORMAT function before combing them.

To further improve your DAX skills, you might want to consider taking additional courses on the Enterprise DNA Platform. They offer a wide range of tutorials and lessons on topics that will help enhance your professional development in the field.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

This task aims to create a new column in a DAX table by combining the values of two existing columns. The chosen columns, "Itemno.1" and "Trim", from the "Label Reorder Summary" table, are concatenated using the "COMBINEVALUES" function. The resulting string is then assigned to a new column named "Combined" in the same table. It is essential to ensure that the selected columns exist in the table and are in text format. If not, the columns should be converted using the FORMAT function before applying the combination. This task showcases a common and straightforward approach in DAX for creating a calculated column by merging text fields. To further enhance DAX skills, additional courses offered by the Enterprise DNA Platform are recommended. These courses provide comprehensive tutorials and lessons to improve professional development in the field.