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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
JustDavid
Helper IV
Helper IV

Dynamically combine Headers from each table

PQ Gurus,

 

Apologies in advanced that I can't share sample pbix file as i don't know how to create a "table" in each row.

 

Hopefully my screenshot can show you and that you're able to understand what I desired to achieve.

 

This is the result of one of the applied steps (call it 'PromoteHeader').

 

As you can see, in the [Data] column (denotes by the top right of screenshot), I have Table "result" on each row (what is the correct terminology for this so that everyone understand? Table Row?). And when I click on each of that Table "result", I'd have a preview of the data.

 

What I'd like to ahieve at the end result is to get a distinct column/headers names as list for expansion later on.

 

In order to do that, the logic is:

  1. Loop through each Table row.
  2. On that table, get the header column names.
  3. Combine all the headers and get the unique header names in which I'd use this to expand in my later step.

Table Result in Each Row.png

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

This might work for you...

let
    Source = 
    #table(
        type table [Name=nullable text, Data = table],
        {
            {"File1", #table({"Column1", "Column2"},{{"R1C1", "R1C2"},{"R2C1", "R2C2"}})},
            {"File2", #table({"Column1", "Column3"},{{"R1C1", "R1C2"},{"R2C1", "R2C2"}})},
            {"File3", #table({"Column2", "Column4"},{{"R1C1", "R1C2"},{"R2C1", "R2C2"}})}
        }
    ),
    Add_Header_Names_List = Table.AddColumn(Source, "HeaderNames", each Table.ColumnNames([Data]), type list),
    Get_Distinct_Header_Names = List.Distinct(List.Combine(Add_Header_Names_List[HeaderNames]))
in
    Get_Distinct_Header_Names

jgeddes_0-1758742846585.pngjgeddes_1-1758742857265.pngjgeddes_2-1758742867132.pngjgeddes_3-1758742878730.png

 





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

Proud to be a Super User!





View solution in original post

1 REPLY 1
jgeddes
Super User
Super User

This might work for you...

let
    Source = 
    #table(
        type table [Name=nullable text, Data = table],
        {
            {"File1", #table({"Column1", "Column2"},{{"R1C1", "R1C2"},{"R2C1", "R2C2"}})},
            {"File2", #table({"Column1", "Column3"},{{"R1C1", "R1C2"},{"R2C1", "R2C2"}})},
            {"File3", #table({"Column2", "Column4"},{{"R1C1", "R1C2"},{"R2C1", "R2C2"}})}
        }
    ),
    Add_Header_Names_List = Table.AddColumn(Source, "HeaderNames", each Table.ColumnNames([Data]), type list),
    Get_Distinct_Header_Names = List.Distinct(List.Combine(Add_Header_Names_List[HeaderNames]))
in
    Get_Distinct_Header_Names

jgeddes_0-1758742846585.pngjgeddes_1-1758742857265.pngjgeddes_2-1758742867132.pngjgeddes_3-1758742878730.png

 





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

Proud to be a Super User!





Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors