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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Victorien
New Member

How to link two data table in one visual

Hi everyone, 

 

In my PowerBI, I have two table with different informations. But on both, one value are the same and permit to link these tables directly. 

 

I've the following question : Is it possible in powerBI to have a table visual in wich one we can find first the data of the table A and when we click maybe on a + icon the lign develop and display the values of the table B ?

Victorien_0-1738658612821.png

 

I hope they exist a solution to create this visual 😊

 

Thanks by advance for your help !

 

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

Hi @Victorien ,

Thanks for Sergii24's reply!
And @Victorien , I don't think Power BI can fully implement your visual.

vjunyantmsft_0-1738732523218.png


If you really need to have a "+" (that is, the ability to expand the hierarchy), then you can only use the matrix visual object to achieve it. However, the default matrix of Power BI does not allow multiple rows of column headers at the same level.

vjunyantmsft_1-1738732644144.png

vjunyantmsft_2-1738732654976.png

vjunyantmsft_3-1738732666415.png

This means that these three lines cannot appear in the same visual object at the same time.

In addition, all the data that needs to be column headers in your two tables are in the same row. Power BI cannot use the data in a row to put into a visual object. It can only put a column or a measure into a visual object. You must modify your data model.

I can provide you with two workarounds:
1. Matrix visual:
Use this DAX to create a calculated table:

 

 

FinalTable = 
UNION(
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column1],
        "sub-level", TableB[Column1]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column2],
        "sub-level", TableB[Column2]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column3],
        "sub-level", TableB[Column3]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column4],
        "sub-level", TableB[Column4]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column5],
        "sub-level", TableB[Column5]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column6],
        "sub-level", TableB[Column6]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column7],
        "sub-level", TableB[Column7]
    )
)

 

 

Output:

vjunyantmsft_4-1738732907729.png

Then in this new table, use this DAX to create a calculated column:

 

 

Index = 
COUNTROWS(
    FILTER(
        'FinalTable',
        'FinalTable'[Number] = EARLIER('FinalTable'[Number]) &&
        'FinalTable'[parent hierarchy] = EARLIER('FinalTable'[parent hierarchy]) &&
        'FinalTable'[sub-level] <= EARLIER('FinalTable'[sub-level])
    )
)

 

 

vjunyantmsft_5-1738732952653.png

Then create the matrix visual:

vjunyantmsft_6-1738732993482.png

You can use filter or slicer to choose the Number you want to see:

vjunyantmsft_7-1738733024869.png

vjunyantmsft_8-1738733034821.png


2. Table visual (If you can accept the lack of hierarchy expansion, just without "+"):
Use this DAX to create a calculated table:

 

 

CombinedTable = 
UNION(
    SELECTCOLUMNS(TableA, "Number", TableA[Number], "Column1", TableA[Column1], "Column2", TableA[Column2], "Column3", TableA[Column3], "Column4", TableA[Column4], "Column5", TableA[Column5], "Column6", TableA[Column6], "Column7", TableA[Column7], "Source", "TableA"),
    SELECTCOLUMNS(TableB, "Number", TableB[Number], "Column1", TableB[Column1], "Column2", TableB[Column2], "Column3", TableB[Column3], "Column4", TableB[Column4], "Column5", TableB[Column5], "Column6", TableB[Column6], "Column7", TableB[Column7], "Source", "TableB")
)

 

 

vjunyantmsft_9-1738733166937.png

Then create the Table visual:

vjunyantmsft_10-1738733204394.png


But no matter what, the default visual objects of Power BI cannot fully meet your needs. Perhaps you can also look for visual objects in custom visuals that can fully achieve or are closer to your expected results. Thank you!

vjunyantmsft_0-1738733533754.png


Best Regards,
Dino Tao
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

2 REPLIES 2
v-junyant-msft
Community Support
Community Support

Hi @Victorien ,

Thanks for Sergii24's reply!
And @Victorien , I don't think Power BI can fully implement your visual.

vjunyantmsft_0-1738732523218.png


If you really need to have a "+" (that is, the ability to expand the hierarchy), then you can only use the matrix visual object to achieve it. However, the default matrix of Power BI does not allow multiple rows of column headers at the same level.

vjunyantmsft_1-1738732644144.png

vjunyantmsft_2-1738732654976.png

vjunyantmsft_3-1738732666415.png

This means that these three lines cannot appear in the same visual object at the same time.

In addition, all the data that needs to be column headers in your two tables are in the same row. Power BI cannot use the data in a row to put into a visual object. It can only put a column or a measure into a visual object. You must modify your data model.

I can provide you with two workarounds:
1. Matrix visual:
Use this DAX to create a calculated table:

 

 

FinalTable = 
UNION(
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column1],
        "sub-level", TableB[Column1]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column2],
        "sub-level", TableB[Column2]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column3],
        "sub-level", TableB[Column3]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column4],
        "sub-level", TableB[Column4]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column5],
        "sub-level", TableB[Column5]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column6],
        "sub-level", TableB[Column6]
    ),
    SELECTCOLUMNS(
        GENERATE(
            TableA,
            FILTER(
                TableB,
                TableA[Number] = TableB[Number]
            )
        ),
        "Number", TableA[Number],
        "parent hierarchy", TableA[Column7],
        "sub-level", TableB[Column7]
    )
)

 

 

Output:

vjunyantmsft_4-1738732907729.png

Then in this new table, use this DAX to create a calculated column:

 

 

Index = 
COUNTROWS(
    FILTER(
        'FinalTable',
        'FinalTable'[Number] = EARLIER('FinalTable'[Number]) &&
        'FinalTable'[parent hierarchy] = EARLIER('FinalTable'[parent hierarchy]) &&
        'FinalTable'[sub-level] <= EARLIER('FinalTable'[sub-level])
    )
)

 

 

vjunyantmsft_5-1738732952653.png

Then create the matrix visual:

vjunyantmsft_6-1738732993482.png

You can use filter or slicer to choose the Number you want to see:

vjunyantmsft_7-1738733024869.png

vjunyantmsft_8-1738733034821.png


2. Table visual (If you can accept the lack of hierarchy expansion, just without "+"):
Use this DAX to create a calculated table:

 

 

CombinedTable = 
UNION(
    SELECTCOLUMNS(TableA, "Number", TableA[Number], "Column1", TableA[Column1], "Column2", TableA[Column2], "Column3", TableA[Column3], "Column4", TableA[Column4], "Column5", TableA[Column5], "Column6", TableA[Column6], "Column7", TableA[Column7], "Source", "TableA"),
    SELECTCOLUMNS(TableB, "Number", TableB[Number], "Column1", TableB[Column1], "Column2", TableB[Column2], "Column3", TableB[Column3], "Column4", TableB[Column4], "Column5", TableB[Column5], "Column6", TableB[Column6], "Column7", TableB[Column7], "Source", "TableB")
)

 

 

vjunyantmsft_9-1738733166937.png

Then create the Table visual:

vjunyantmsft_10-1738733204394.png


But no matter what, the default visual objects of Power BI cannot fully meet your needs. Perhaps you can also look for visual objects in custom visuals that can fully achieve or are closer to your expected results. Thank you!

vjunyantmsft_0-1738733533754.png


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

Sergii24
Super User
Super User

Hi @Victorien, you can obtain a desired result using matrix visual and if an element on a top row is somehow related to subelements (let's say A is a sum of I, II and III; or it's minimum and etc.)

 

Even if they are not related, there is Power BI function called INSCOPE() that allows you to calculate different expressions depending on what level of hierarchy you are. However, if you're new to Power BI it won't be simple as requires a fair understadning of DAX language.

 

The simplest option is to use a boomark and show or table A or table B.

 

Good luck with you project! 🙂 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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