Forum Discussion
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
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
5 Replies
- amitchandak
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
- v-yingjl
Community Support
Hi rkumar ,
When using union() expression, you should note that:
- The two tables must have the same number of columns.
- Columns are combined by position in their respective tables.
- The column names in the return table will match the column names in table_expression1.
- 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 LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
- rkumar
Helper 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
Community 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 LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.