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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
kesham
Frequent Visitor

add rows from multiple table with same type

Hello everyone, I am new in power bi and I try to make a table combining rows of 2 table:

for example :

table 1 (column A,B & C) where A is strings, B & C are int with 1000 rows

table 2(column D & E) where D is string and E is int with 500 rows

 

What I want il making the table 3 with 2 columns (F & G) where F is string and G is int with all the rows ofcouples A&B, A&C, D&E.

At the end Table 3 will have 2500 rows

 

Can someone help me ?

kind regards

 

PS: it would be awesom to know from where is the data with a new strin column H with 3 cases ("Table1 A&B";"Table1 A&C";"Table2 D&E") just to know where the data is from.

 

kind regards again 🙂

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@kesham - You could combine tables in 3 ways:

1. Prior to bringing in to Power BI

2. In Power Query -

  2.1 Make a Duplicate of Table1

  2.2 Remove B from one of the tables and C from the other.

  2.3 Change column names so that all 3 tables have the same column names.

  2.4 Add a Custom Column to each of the 3 tables, describing the source.

  2.5 Append tables together into 1.

3. In DAX: Create a Calculated Table like this:

My Combined Table =
var a = SELECTCOLUMNS(Table1,"F",[A],"G",[B],"H","Table1 A&B")
var b = SELECTCOLUMNS(Table1,"F",[A],"G",[C],"H","Table1 A&C")
var c = SELECTCOLUMNS(Table2,"F",[D],"G",[E],"H","Table2")
return UNION(a,b,c)
 
Cheers!
Nathan

View solution in original post

1 REPLY 1
Anonymous
Not applicable

@kesham - You could combine tables in 3 ways:

1. Prior to bringing in to Power BI

2. In Power Query -

  2.1 Make a Duplicate of Table1

  2.2 Remove B from one of the tables and C from the other.

  2.3 Change column names so that all 3 tables have the same column names.

  2.4 Add a Custom Column to each of the 3 tables, describing the source.

  2.5 Append tables together into 1.

3. In DAX: Create a Calculated Table like this:

My Combined Table =
var a = SELECTCOLUMNS(Table1,"F",[A],"G",[B],"H","Table1 A&B")
var b = SELECTCOLUMNS(Table1,"F",[A],"G",[C],"H","Table1 A&C")
var c = SELECTCOLUMNS(Table2,"F",[D],"G",[E],"H","Table2")
return UNION(a,b,c)
 
Cheers!
Nathan

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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