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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to join two tables based on a row of one and a column of the other?

Hello

 

I have the data:

 

Name; Index;

A           1

B           2

C           3

etc

 

I also have created an empty table and added calculated columns so that the following table is created:

       1;          2;         3;

Calc1;    Calc2;   Calc3

etc

 

How can I create the table:

Name; Index;  Calc;

A           1       Calc1

B           2        Calc2

C           3        Calc3

 

Thanks! By the way, if you have any better strategy to put calculations/measures in rows, please let me know! So that, I get the table above without creating two separate tables and trying to join them.

 

 

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

Hi @Anonymous ,

 

1. Create a calculated table.

Table 3 = 
VAR X=
UNION(
    SELECTCOLUMNS( 'Table (2)',"C1", MAX('Table (2)'[Column1]), "C2", MIN('Table (2)'[Column1]) ),
    SELECTCOLUMNS( 'Table (2)', "C1", MAX('Table (2)'[Column2]), "C2", MIN('Table (2)'[Column2]) ),
    SELECTCOLUMNS( 'Table (2)', "C1", MAX('Table (2)'[Column3]), "C3", MIN('Table (2)'[Column3]) )
)
RETURN
DISTINCT(
    X
)

ff6.PNG

2. Create a calculated column.

ff7.PNG

 

Best regards,
Lionel Chen

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

4 REPLIES 4
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

1. Create a calculated table.

Table 3 = 
VAR X=
UNION(
    SELECTCOLUMNS( 'Table (2)',"C1", MAX('Table (2)'[Column1]), "C2", MIN('Table (2)'[Column1]) ),
    SELECTCOLUMNS( 'Table (2)', "C1", MAX('Table (2)'[Column2]), "C2", MIN('Table (2)'[Column2]) ),
    SELECTCOLUMNS( 'Table (2)', "C1", MAX('Table (2)'[Column3]), "C3", MIN('Table (2)'[Column3]) )
)
RETURN
DISTINCT(
    X
)

ff6.PNG

2. Create a calculated column.

ff7.PNG

 

Best regards,
Lionel Chen

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

mahoneypat
Microsoft Employee
Microsoft Employee

You should unpivot or transpose your second table, and then you can merge the two on Index to create your desired output.

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Unfortunately this does not work. It is not possible to transpose the table because the added calculated columns do not appear in the Table under Edit Queries.

 

Any other solution?

Anonymous
Not applicable

The issue you're facing is one more reason why one should try NOT to use calculated columns. There are many more reasons, of course.

If you can add/create the columns in Power Query (and it's hardly imaginable you couldn't), you'll have no problems doing what you want and you'll get the benefits of correct compression, and hence faster DAX.

Best
D

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors