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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pbzmz
Regular Visitor

Merging two columns from two tabels into one column

I've got 2 columns in 2 different tabels but my data in the table are complementary.

As i show you on this screenshot.

pbzmz_0-1663924460095.png

And i want to merge them to one column, but i doesn't exacly know how to do it.

 

 

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @pbzmz ,

 

If your two tables have the same number of columns, consider using the UNION() function.

 

My test table1:

vyadongfmsft_0-1664169973850.png

 

My test table2:

vyadongfmsft_1-1664169995435.png

 

Please try following DAX:

Table = UNION('Table1','Table2')

 

vyadongfmsft_2-1664170111489.png

 

Best regards,

Yadong Fang

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

10 REPLIES 10
v-yadongf-msft
Community Support
Community Support

Hi @pbzmz ,

 

If your two tables have the same number of columns, consider using the UNION() function.

 

My test table1:

vyadongfmsft_0-1664169973850.png

 

My test table2:

vyadongfmsft_1-1664169995435.png

 

Please try following DAX:

Table = UNION('Table1','Table2')

 

vyadongfmsft_2-1664170111489.png

 

Best regards,

Yadong Fang

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

lukiz84
Memorable Member
Memorable Member

Do you load them in PowerQuery? Tell us a little more about the structure 🙂

pbzmz_1-1663926561121.png

 

In K3513 i have one column called "cena" and in the K3510 i have other column called "cena".

And in !Miary, "Tabela", i want to create new column that will merge those two column that i just mention

lukiz84
Memorable Member
Memorable Member

After doing same thing from this video it's showing me column full of zeros.

lukiz84
Memorable Member
Memorable Member

Is "Tabela" empty or are there already values in it? Where does Tabela come from?

I've managed to merge both files in excel so I have everything in one table now.

But i have one additional question. My column named "cena", has numbers in it, and when i throw them to matrix, it shows me column "cena" as sum. And I don't want it

lukiz84
Memorable Member
Memorable Member

That's normal (implicit measure). 

 

See Explicit Vs Implicit DAX Measures in Power BI - RADACAD

 

If you want to just have the value in your Matrix you have to format it as Text or create a Measure which you then place on the matrix. The Measure can be something like MIN(Cena) or TEXT(cena, "0000")

lukiz84
Memorable Member
Memorable Member

Hi,

-In DAX: Create a new Calculated column:

MergedColumn := IF([Col1]<>BLANK(), [Col1], [Col2])

-In PowerQuery: Add a custom column:

Table.AddColumn(tbl, "MergedColumn", each if [Col1] <> null then [Col1] else [Col2])

 

It's good if i have two columns in one table. But i've got two columns. Two different files. And i need to merge one column from one file, and one column from second file.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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