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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
amay15
Frequent Visitor

Join Two Tables

            
Sl noItemCode Sl noParent ItemChild Item Sl noProgramSub ProgramProject
1AProgram 1AB 1ABD
2BSub program 2BD 2CNullE
3CProgram 3AD   Result  Table 
4DProject   4 C E     
5EProject   Table      
           
 Table  1         
2 REPLIES 2
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @amay15

 

It seems you may use 'pivot columns' and 'merge queries' in Query Editor to achieve that.


Regards,

Cherie

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

@amay15 I've tried to solve this in DAX as below:

 

Please add below two columns (supporting columns) in Table 2 as below

 

Exclude = 
VAR _Flag1 = LOOKUPVALUE(Test136ParentChild[Parent],Test136ParentChild[Parent],Test136ParentChild[Child])
VAR _Flag2 = LOOKUPVALUE(Test136ParentChild[Child],Test136ParentChild[Child],Test136ParentChild[Parent])
RETURN IF(Test136ParentChild[Parent]=_Flag1 || Test136ParentChild[Parent]=_Flag2,"Y","N")
Child1 = LOOKUPVALUE(Test136ParentChild[Parent],Test136ParentChild[Parent],Test136ParentChild[Child])

 

Then, Please try this as a "New Table"

 

Test136Out = 
VAR _Temp = ADDCOLUMNS( 
                        CALCULATETABLE(Test136ParentChild,Test136ParentChild[Exclude]<>"Y")
                        ,"Program",Test136ParentChild[Parent]
                        ,"SubProgram",IF(Test136ParentChild[Child]=Test136ParentChild[Child1],Test136ParentChild[Child])
                        ,"Project",IF(Test136ParentChild[Child1]=BLANK(),Test136ParentChild[Child])
                      )

RETURN SELECTCOLUMNS(_Temp,"Program",[Program],"SubProgram",[SubProgram],"Project",[Project])  

image.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors