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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
melian
Frequent Visitor

How to combine three columns into one?

Hi, 

 

I have a table that has three columns (Zip codes columns). I want to combine all of them into one column that has all the zip codes. How can I do that? 

1 ACCEPTED SOLUTION

@melian,

 

You may select Unpivot Columns in the Query Editor or use UNION Function in DAX.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

13 REPLIES 13
jakobob
New Member

Hey!
There's no build in function in Power BI for that, but you can use M/Power query. 

(Source) =>
    let
        result = Table.FromList(List.Combine(Table.ToColumns(Source)), null, {"AllZipCodes"})
    in
        result

 Just google for how to apply Power Query to your Power BI. 
However this function replaces all your columns. If you want to keept the old columns you got to customize the function. 

Cheers Jakobob

bharatmalvi
Frequent Visitor

how to do the same using power query?

Anonymous
Not applicable

Hi @melian

Could you please post some sample data to replicate your issue???

 

 

Regards,

Angad

zipcode ss 1.PNG

 

This is an example of what I want to do. In the table I am working on there are three columns, the first three, of zipcodes. I want to combine all of them into one column, All ZipCodes. 

@Anonymous

Anonymous
Not applicable

Hi,

 

Use Summarize with union function as shown below-

 

AllZipCode =
UNION(SUMMARIZE('Table','Table'[ZipCode1]),SUMMARIZE('Table','Table'[ZipCode2]),SUMMARIZE('Table','Table'[ZipCode3]))
 
Angad

@AngadK , i have a similar requirement, tried the union dax with Summarize its throwing an error, can you please help me with this

 
 
Project IDs = UNION(SUMMARIZE('Table','Table'[Project_ID1]),SUMMARIZE('Table','Table'[Project_ID2]),SUMMARIZE('Table','Table'[Project_ID3]),SUMMARIZE('Table','Table'[Project_ID4]))
Anonymous
Not applicable

@Jack11 , Have you written the union dax formula on "Create a new table using DAX" pane?

@Anonymous , i got if after using the dax in a new table, is it possible to combine them in the same table?

What i want: am planning to show the hours spent on each project on a particular date, i have 4 columns of project IDs for each person everyday hence i want to combine the IDs into one column.

Hi Melian, Can you please post your solution DAX . I have the same requirement but UNIOn is not working in my case.

@melian,

 

You may select Unpivot Columns in the Query Editor or use UNION Function in DAX.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft Thank you so much. The UNION function did the job. Much appreciated. 

CONCATENATE([col1],CONCATENATE([col2],[col3]))

melian
Frequent Visitor

@Gokul

The problem with this is that it combines them on the same line, which is not what I want. Your code would make the the new list looks like this 

 

 zipcode ss 2.PNG

 

 

However, I want the new list to look like this 

zipcode ss 1.PNG

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.