Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
rkumar
Helper III
Helper III

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.

 

zipcode.png

Thank You

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Thank You,

Instead of creating a union column we used slicer having souce from 3 columns , user below community link to get my work done. 

community.powerbi.com/t5/Desktop/How-to-filter-on-multiple-columns/td-p/380232  

View solution in original post

5 REPLIES 5
v-yingjl
Community Support
Community 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:

union result.png

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.

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

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.

Thank You,

Instead of creating a union column we used slicer having souce from 3 columns , user below community link to get my work done. 

community.powerbi.com/t5/Desktop/How-to-filter-on-multiple-columns/td-p/380232  

amitchandak
Super User
Super User

Try

New table  = union(all(table[zipcode1]),all(table[zipcode2]),all(table[zipcode3]))

Or

new table = distinct(union(all(table[zipcode1]),all(table[zipcode2]),all(table[zipcode3])))

Also try

https://radacad.com/append-vs-merge-in-power-bi-and-power-query

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.