Forum Discussion

rkumar's avatar
rkumar
Icon for Helper III rankHelper III
6 years ago
Solved

Joining data from 3 columns into 1 column

Hi All,

In the table I am working on three columns, the first three are zipcodes. I want to combine all of them into one column, All ZipCodes. Union DAX syntax is not working for me. Please suggest the DAX.

 

Thank You

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5 Replies

  • v-yingjl's avatar
    v-yingjl
    Icon for Community Support rankCommunity Support

    Hi rkumar ,

    When using union() expression, you should note that:

    1. The two tables must have the same number of columns.
    2. Columns are combined by position in their respective tables.
    3. The column names in the return table will match the column names in table_expression1.
    4. Duplicate rows are retained.

    You can create a new table to use union() expression:

    All codes = 
            UNION(
            DISTINCT('Table'[Code1]),
            DISTINCT('Table'[Code2]),
            DISTINCT('Table'[Code3])
            )

    You will get the expected result:

    Best Regards,
    Yingjie Li

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

    • rkumar's avatar
      rkumar
      Icon for Helper III rankHelper III

      Hi Yingjie ,

      I am using only one table, need to combine data from 3 columns of this table in one column. moreover the data of this new column has to be used in slicer so new table is not feasible. Please suggest.

       

      Thank You

      • v-yingjl's avatar
        v-yingjl
        Icon for Community Support rankCommunity Support

        Hi rkumar ,

        I'm afraid you cannot create it in one table beacuse if you want to create a new column in the same table to combine other columns, there is no value which correspond with each row as the error message said 'A table of multiple values was supplied where a single value was expected' when you create a column need to have 9 rows while the columns you want to combine just have 3 rows.

         

        Best Regards,
        Yingjie Li

        If this post helps then please consider Accept it as the solution to help the other members find it more quickly.